-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Replace dots with underscores in id
and href
attributes for generated HTML documentation
#11208
Comments
I'm happy to put in the work here, but would appreciate some guidance from more senior devs on what is the right way to do this. The PR linked above might provide a useful template, or not. |
After some more thoughts, we realized that the issue related to the anchor naming convention is only a problem when using the built-in ScrollSpy from Twitter Bootstrap. I think it should then be handled by us from the theme itself (either by using a custom SccrollSpy or use a bootstrap trick) and not from here. @AA-Turner I let you review pydata/pydata-sphinx-theme#1435 and I think you can close this one. |
I've read the linked issue as well as the Bootstrap one. Since the latter agrees that dots are valid HTML5 ids, I think we can indeed close this issue. On the other hand, we could change. by - but I am wondering whether we used the . to separate a name and a number. If this is the case, we may also need to change the design on our side to be a bit more robust, e.g., by having two dashes. Otherwise we can just change it normally. |
As the names are actual python names I don't think you can face a dots that separate a name and a number as you can't set a variable name as a number. |
Err, I don't understand the names. What do you mean by "python names"? they are just strings stored in the |
ah sorry. These names are generated when documenting APIs via autodoc. The dots are just representing the path to the method in a python framework:
With of course all the alternative possible if you document a package variable, a module function, a submodule ... etc |
Ok, so we should keep those dots on our side because they are meaningful (actually I took the thing with name/number from the issues you linked and your examples with "id.1" etc). |
sure no problem. That's why I suggested to close the issue in the first place. |
Thank you. It's just that I wanted to be sure that we were on the same page. Now, I'll close the issue. |
Is your feature request related to a problem? Please describe.
When generating HTML documentation with
autodoc
andsphinx-build
, nodes representing documented Python objects (e.g.<section>
tags for modules & submodules,<dt>
&<dd>
tags for function & method signatures) are assignedid
attributes that may contain dots. Likewise, thehref
of any reference nodes pointing to those nodes will also contain dots. Dots are not valid for JavaScript identifiers, and will break things like ScrollSpy. See the related issue with PyData Sphinx theme.This might be considered a bug, although the presence of dots is not strictly invalid in HTML. But since HTML documentation is generally intended to be served over a web interface, it should be able to play nicely with modern web ecosystems.
Describe the solution you'd like
HTMLTranslator
classes should replace dots with underscores when assigningids
of nodes representingautodoc
'd Python members, and therefuri
andanchorname
attributes of any reference nodes pointing to those members. Personally I think this should be the default behavior, but it would be acceptable to add an option (e.g. tosphinx-build
) that would allow the user to toggle this behavior.Describe alternatives you've considered
The user can define a custom
HTMLTranslator
that handles this, as demonstrated in the PR submitted to PyData Sphinx theme.The text was updated successfully, but these errors were encountered: