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

show source code of properties #654

Merged
merged 9 commits into from
Dec 22, 2023
Merged

Conversation

tmeyier
Copy link
Contributor

@tmeyier tmeyier commented Dec 22, 2023

I think, that pdoc should show the show the source code of properties.

To realize that functionality, the source code of the property function needs to be transferred to the corresponding Variable object, that is used inside the jinja2 template.

The example function bla.py is still in for testing purposes. I'll look into updating the test suite.

closes #653

@tmeyier
Copy link
Contributor Author

tmeyier commented Dec 22, 2023

I tried to reproduce the lint failures locally. But I get the error below - even with a freshly cloned pdoc.

I'm using a conda environment with python 3.9, installed the dependencies with conda first and then did
git clone https://github.com/mitmproxy/pdoc.git pdoc
cd pdoc
pip install -e .
tox
Is there something wrong with my setup or is this an issue with pdoc ?

(3.9) thorsten@gustav:~/src/pdoc_original$ tox
lint: commands[0]> ruff .
lint: commands[1]> mypy pdoc test
test/testdata/misc_py312.py:14: error: invalid syntax [syntax]
Found 1 error in 1 file (errors prevented further checking)
lint: exit 2 (0.13 seconds) /home/thorsten/src/pdoc_original> mypy pdoc test pid=18128
lint: FAIL ✖ in 0.17 seconds
[...]

@tmeyier tmeyier changed the title draft: show source code of properties draft: show source code of properties (closes #653) Dec 22, 2023
@tmeyier tmeyier marked this pull request as draft December 22, 2023 11:24
@tmeyier tmeyier changed the title draft: show source code of properties (closes #653) show source code of properties (closes #653) Dec 22, 2023
@tmeyier tmeyier changed the title show source code of properties (closes #653) show source code of properties Dec 22, 2023
@tmeyier
Copy link
Contributor Author

tmeyier commented Dec 22, 2023

The line numbers of the @Property source don't come out right yet. formatter options need to be set as well.

Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Please also add an entry in CHANGELOG.md. :)

Normally I'd insist on test coverage, but looks like we already have plenty of examples in the existing tests where this shows, so no action necessary!

bla.py Outdated Show resolved Hide resolved
pdoc/doc.py Outdated Show resolved Hide resolved
@mhils
Copy link
Member

mhils commented Dec 22, 2023

In terms of workflow: Please feel free to just add more commits here, no rebasing etc. necessary. We'll squash everything into one commit in the end anyhow. :)

@tmeyier tmeyier marked this pull request as ready for review December 22, 2023 19:55
Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you so much for contributing this! 😃 🍰 I thought this would be much more difficult, but you've found a fantastic workaround here.

@mhils mhils enabled auto-merge (squash) December 22, 2023 22:47
@mhils mhils merged commit 44ece4c into mitmproxy:main Dec 22, 2023
12 checks passed
@tmeyier tmeyier deleted the show_property_source branch December 23, 2023 11:41
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

Successfully merging this pull request may close these issues.

"View Source" button for @property, @cached_property methods
2 participants