Skip to content
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

[Doc/Dev] Off-by-one errors for line numbers in documentation source #4038

Open
DanielYang59 opened this issue Sep 4, 2024 · 1 comment
Open
Labels
bug docs Documentation, examples, user guides needs investigation Needs further research to pinpoint cause of issue

Comments

@DanielYang59
Copy link
Contributor

DanielYang59 commented Sep 4, 2024

The source code line numbers generated from:

filename = f"pymatgen/core/{rel_path}#L{line_start}-L{line_end}"

Seems to have off-by-one errors for some classes, but not all.

For example in https://pymatgen.org/pymatgen.alchemy.html, pointer to AbstractStructureFilter is correct, but off-by-one for ChargeBalanceFilter

image
@janosh janosh added bug docs Documentation, examples, user guides needs investigation Needs further research to pinpoint cause of issue labels Sep 4, 2024
@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Oct 30, 2024

I'm currently looking into this. I believe this linkcode_resolve is working correctly, and the issue should be related to the source code locating mechanism.

The final URL is reported on a specific version (the correct behaviour):

return f"https://github.com/materialsproject/pymatgen/blob/v{__version__}/src/{filename}"

However the source code locating is done on sys.modules, meaning it would depend on what version of pymatgen is installed on the person what called linkcode_resolve, and as developers tend to install pymatgen in editable mode, the page number in editable package and the published static version might be inconsistent.

obj = sys.modules[info["module"]]

I believe this would be resolved by #4056, i.e. automate the docs building process and install corresponding static version of pymatgen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug docs Documentation, examples, user guides needs investigation Needs further research to pinpoint cause of issue
Projects
None yet
Development

No branches or pull requests

2 participants