Access to Sphinx AST before transforms/post-transforms

7 views
Skip to first unread message

Matt McKay

unread,
Aug 9, 2020, 9:49:42 PM8/9/20
to sphinx-users
Hi Sphinx Group. 

Is there a way to access the Sphinx abstract syntax tree (AST) before any transforms or post-transforms are applied (i.e. directly after the parser phase)?

I am writing an extension to convert reST to Myst syntax but I am finding restoring some of the information contained in the original rst file difficult to recover. The key example is a `toctree` that uses the `:hidden:` option appears to be dropped from the AST here (https://github.com/sphinx-doc/sphinx/blob/e4a55cb76f7f45e74997017b8fa4ca913d0ac602/sphinx/environment/adapters/toctree.py#L65)

Any tips / hints would be great -- thanks for your time. 

Cheers,
Matt

Komiya Takeshi

unread,
Aug 9, 2020, 10:22:58 PM8/9/20
to sphinx...@googlegroups.com
Hi,

How about using a transform having a very high priority? Then you can
access a doctree (a.k.a. AST) just after the parsed.

Thanks,
Takeshi KOMIYA

2020年8月10日(月) 10:49 Matt McKay <mam...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/1e767f7a-6a03-4a0d-a22d-4326716299c3o%40googlegroups.com.

Matt McKay

unread,
Aug 9, 2020, 10:30:52 PM8/9/20
to sphinx...@googlegroups.com
Thanks Takeshi -- that is a nice idea. I will give that a shot. 

Daniel Scott

unread,
Nov 25, 2020, 10:35:22 PM11/25/20
to sphinx...@googlegroups.com
--
Reply all
Reply to author
Forward
0 new messages