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

Improve line numbers for docstrings #12894

Open
dimaqq opened this issue Sep 17, 2024 · 4 comments
Open

Improve line numbers for docstrings #12894

dimaqq opened this issue Sep 17, 2024 · 4 comments
Labels
domains:py expert issue that is not easily fixed internals:other type:proposal a feature suggestion

Comments

@dimaqq
Copy link

dimaqq commented Sep 17, 2024

I get warnings like this:

/code/operator/ops/__init__.py:docstring of ops:42: WARNING: py:attr reference target not found: ...

The thing is, the file starts with a large comment preamble (you may use this software...) and line 42 of the docstring corresponds to line 56 of the file in my case.

Which means that for large multiline docstrings, the docstring line number is not very useful.

Could Sphinx show this instead?

/code/operator/ops/__init__.py:56: docstring of ops: WARNING: py:attr reference target not found: ...
@dimaqq dimaqq added the type:proposal a feature suggestion label Sep 17, 2024
@picnixz
Copy link
Member

picnixz commented Sep 21, 2024

We don't necessarily know where the oroginal docstring is so I'm not sure we can actually do it. If you manually specify a docstring via __doc__, we won't know the offset. And we cannot distinguish (easily) a "static" docstring from a dynamic one.

It's possible to do it by improving the static analysis but it's hard I think. Nonetheless maybe we do record where the docs are being added though.

In addition, there is also the possibility for the docstring to be altered by some event handler so we also need to keep track of each docstring state which might blow up the memory usage (which is already massive).

@dimaqq
Copy link
Author

dimaqq commented Sep 22, 2024

Ahh I didn’t think about that.

Let me ask Python ideas.

@picnixz
Copy link
Member

picnixz commented Sep 23, 2024

It's not really a Python issue. It's just that we have a limited static analysis and that we need to improve it on our side.

It's probably possible to have the real line number but it'll be a not-so-simple task!

@jayaddison jayaddison added domains:py internals:other expert issue that is not easily fixed labels Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domains:py expert issue that is not easily fixed internals:other type:proposal a feature suggestion
Projects
None yet
Development

No branches or pull requests

3 participants