Skip to content

Code blocks with a way to cross-reference library entities #11389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cjdb opened this issue Apr 30, 2023 · 5 comments
Open

Code blocks with a way to cross-reference library entities #11389

cjdb opened this issue Apr 30, 2023 · 5 comments

Comments

@cjdb
Copy link

cjdb commented Apr 30, 2023

Is your feature request related to a problem? Please describe.
I use code-block:: cpp to demonstrate how features in work quite extensively, and it would be beneficial for readers to be able to click on the entities that are mentioned and go to the page that references them (if they're available).

Describe the solution you'd like
The example section of cppreference's std::array page is a good example of what I'd like. Notice that it's possible to click on std::string, which takes you through to the std::string documentation page.

@humitos
Copy link
Contributor

humitos commented Apr 30, 2023

Something like this would work for your use case? https://sphinx-codeautolink.readthedocs.io/en/latest/

@picnixz
Copy link
Member

picnixz commented Apr 30, 2023

@humitos I think the extension you linked is only for Python-like code since it uses an Python AST approach.

@cjdb
Copy link
Author

cjdb commented Apr 30, 2023

The extension docs also imply that it's Python only (but it is good to know that other people want this enough to write an extension!).

@AA-Turner
Copy link
Member

I think this is very reasonable, the challenge would be implementing a lexer to run over code blocks, though likely a lot of the machinery exists already as of the support for object description directives.

Do you happen to know how the C++ reference implement their functionality?

A

@cjdb
Copy link
Author

cjdb commented Apr 30, 2023

cppreference uses MediaWiki for its backend, and I think this page is how their code blocks are implemented. Something interesting to note is that in

using std::cout; // (1)
cout << x; // (2)

(1) forms a link to std::cout's page, but (2) doesn't, so parsing certainly isn't necessary. That's fine, since I'd even be happy with only the first instance of the name being the link.

std::cout << "Hello, world!\n"; // links
std::cout << "Goodbye, world!\n"; // doesn't link

@AA-Turner AA-Turner added this to the some future version milestone Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants