-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: Add option to scan and register HTML anchors #20
Conversation
Could you please share the repository where you're using this approach of manually adding tags? Also seeing your use case would help justify the fact that we're parsing HTML with regex here, which usually is to be avoided at all costs 😬 On a separate note - are you aware that And we'd have to at least make this option false by default, as it's kind of a breaking change and also it's likely to greatly impact performance. |
The repo I am working on is: https://github.com/tvdboom/ATOM See here for example how I create the Up until now I made all these pages manually, which was a lot of work and not very efficient. I am currently working on an automated way to make the same documentation. See the Let me know if you have any questions.
I am aware that scan_toc was only an internal setting but I tried to follow the "style" of the existing code. I do agree that this should be an option that defaults to False since it has indeed an impact on performance (although not as great as you might expect) based on my current tests (I already implemented this on my local download of autorefs). I'll change the code in the PR as soon as I have time for it. P.S. I am not sure what the ci/quality test should do to pass |
Sorry um this is off-topic, but... is there no way at all to make mkdocstrings work for your usecase? You could probably even subclass the Python handler, replace all templates and such... |
I tried to make it work with mkdocstrings, but it was bugged. Not sure what went wrong but the formatting was all off. Furthermore, the support for numpydoc style is limited. I also didn't know you could overwrite the templates. If it's easy, it would be nice to see that in the docs somewhere. But, to be honest, I don't think I can achieve the level of customization I want with mkdocstrings. Have a look at this page for example. Here, I want to list specific methods and properties at every section (some of them inherited from a parent class and some not), add examples right from the docstring, list properties that are not directly inherited by the class, add a toc at every section, etc... I figured that it would be easier to write my own parser. |
Sigh. Yeah it'd be some work to wrangle mkdocstrings to do this. |
If you can achieve all I just mentioned with mkdocstring, then the problem is the documentation. It needs way more examples on how to achieve all these things. |
No, I don't think one can achieve all of that. Maybe one day 😔 |
I added the scan_html_tags as an option in config |
Hi @tvdboom, thanks for your patience. I understand your use case and I'm not against adding this feature. However registering all HTML IDs of all pages seems like a good way to shoot yourself in the foot. Depending on the set of activated plugins and extensions, there might be lots of those IDs, overlapping with each other, and worse, overlapping with actual API objects. Would it make more sense to only search for actual anchors
|
Yes, that makes sense. For simplicity I would say to only register actual anchors. I updated the PR |
Incredibly late response, but I sort of forgot about this PR. I updated it now. Can someone indicate me where exactly to update the documentation? |
The PR with the slowest pace on GitHub 😂 |
017d66f
to
1465f3b
Compare
I noticed
autorefs
only scans the toc for anchors. This PR enhances the library by also searching for all html tags with theid
attribute. The user might want to useautorefs
to link to any arbitrary html tag that is not part of the toc.Use case: When documenting a Python class, every method can be preceded by a tag
<a id="method_name"></a>
to refer to it. Using markdown headers is not desired in this case because you don't want all the methods listed in the toc.