-
Notifications
You must be signed in to change notification settings - Fork 618
Rewrite Python standard library tags creation script for Python 3 #3039
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
Conversation
The question now is whether not to switch to the ctags file format for the languages which have identical implementation (and therefore kind letters) both in Geany and ctags. I don't know what the script does exactly but if we switched to the ctags file format, wouldn't it be sufficient to run the ctags binary on the corresponding directory with sources? The "proprietary" half-binary format is still useful for our unit tests since it already contains ctags kinds mapped to our internal representation so we can verify this mapping is done correctly. But for the tag files shipped with Geany I think we are more or less ready to switch to the ctags file format and suggest users to use ctags to generate it. |
What about the other languages in |
Yes, vala for instance is missing and those will still have to be generated by Geany if users want them. But all the parsers for the tags under |
Maybe to clarify - as outlined here #3049 (comment) I would suggest switching to the ctags file format. That however doesn't mean that we have to necessarily use ctags to generate such files. We can still use Geany or whatever scripts to write the tag files, just in a different format (I think Geany processes includes and parses the included files automatically which I think ctags doesn't do and might be shame to lose that functionality). The ctags file format is pretty simple and generating it ourselves shouldn't be hard to do. |
I followed your suggestion and changed the output format of the tags file to ctags. |
Well, it isn't something I'm one hundred percent sure we should do, but rather something I wanted to discuss. Also, I had something different in mind - to use Also, if we want to use the ctags format, we should merge #3049, otherwise not all the fields are parsed correctly. To the topic of pros/cons of using the ctags file format, these are the advantages I can think of:
On the other the cons of the ctags format are:
|
Regarding whether to create the Python with ctags instead of this script:
Overall, for me, the generated tags of the script look cleaner and more sane than the ctags ones. For reference, the ctags command I tried:
While playing with the ctags command, I noticed I erroneously set a class' base as parent which is wrong in this context and methods used the wrong kind. Those are fixed.
+1
I'd prefer the ctags format because, as you say, it's the standard format and probably less error prone than the custom tagmanager format. |
OK, it probably makes sense to use the python script also because of all the additional problems you mentioned.
Curious about this one - how does it behave when there are multiple corresponding Line 1867 in 8f35d33
which can look up all One more thing - wouldn't it make sense to factor-out the tag writing code to a separate file so it can be reused by other tag writing scripts? For instance, there's also |
In Python, there is no point in having multiple
Sure we can do that. But IMO both ideas would be better handled in seperate PRs to not blow this one even more. |
Ah, OK, I thought you could have
Yeah, sure. |
I just had a look and it looks good to me. |
I just cleaned the commit history and would like to merge this in a few days if there are no objections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not tested or properly reviewed, but I trust you :)
scripts/create_py_tags.py
Outdated
# If called without command line arguments, a preset of common Python libs is used. | ||
# | ||
# WARNING | ||
# Be aware that running this script will actually *import* modules in the specified directory | ||
# Be aware that running this script will actually *import* all modules given on the command line | ||
# or in the standard library path of your Python installation. Dependent on what Python modules | ||
# you have installed, this might not be want you want and can have weird side effects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[…] what* you want […]
not that it changed in this PR though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing, someone actually read the docs :). Thank you for spotting, fixed.
scripts/create_py_tags.py
Outdated
# Parses all files given on command line for Python classes or functions and write | ||
# them into data/tags/std.py.tags (internal tagmanager format). | ||
# Parses all files in the directories given on command line for Python classes or functions and | ||
# write them into data/tags/std.py.tags (internal tagmanager format). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like it's not in tagmanager format anymore, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for spotting, fixed.
This is a followup of #2630 to fully port the
scripts/create_py_tags.py
script for generating tags for the Python standard library to Python 3.While continuing on @claudep's work, I noticed plain porting is harder than to more or less rewrite the script. Now the script works by fully importing the modules, if possible, to use Python's
inspect.Signature
API to extract symbols. If this is not possible, the existing regular expression based parser is used as fallback.Deprecated modules are ignored completely as well as a couple of special modules like the included Idle IDE and executable modules in general.
I'm using the resulting tags file since a few weeks and it feels fine, much better than before especially because of the better extracted argument lists of functions and methods.