Sphinx domain for Rust #12311
Replies: 1 comment 7 replies
-
ahahaha, I wish you'd posted this about 8 hours ago; that's when I started writing a rust domain 😂 So firstly, I'm obviously not as far along as you in hooking everything up, but I did basically use the same parsing approach as you; with So there are improvements there, and I might be interested to collaborate (I wish you wouldn't be on gitlab 😄) BUT the big issue that I don't see is solved by you or me (with rustdoc does do this, since it uses an intermediate representation generated by the compiler, i.e. after macros have been "expanded": https://rustc-dev-guide.rust-lang.org/rustdoc.html It does this exactly here: https://github.com/rust-lang/rust/blob/25087e02b34775520856b6cc15e50f5ed0c35f50/src/librustdoc/lib.rs#L773 You can view a debug of this intermediate representation like so: rustup run nightly cargo rustc -- -Z unpretty=hir-tree but, to my knowledge, there is no way to hook into this from a third-party crate, without literally building the compiler from source 😒 So, that's the main question I have for you; do you see this as an issue, and can it be solved? |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I just published an alpha version of a Sphinx domain for Rust, along with a supporting Rust executable to generate the directives from the code. The project is https://pypi.org/project/sphinxcontrib-rust/. It is still in early stages, but has most basic functionality.
https://sphinxcontrib-rust.readthedocs.io/en/stable/index.html has the sample output from running the project on itself.
This announcement has two purposes:
Get help with some of the Sphinx internals. Most of this was done by digging through the Python domain's source code, so if someone wants to help me with things like formatting the text of the signatures, adding links for the types in the function signatures, etc. I'd be much obliged. As you can see from the linked docs, the formatting of the Rust directives needs work still.
Get some Rust users to take a look at the extension, give it a spin and provide some feedback on things like the organization of the items and the TOC.
Please let me know if anyone is interested in this. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions