-
Notifications
You must be signed in to change notification settings - Fork 86
(PDOC-37) Warn when documented name does not match declared name #31
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
(PDOC-37) Warn when documented name does not match declared name #31
Conversation
b96d7e0
to
ff21c44
Compare
end | ||
end | ||
|
||
#puts "params #{parameters} tags_hash #{tags_hash}" | ||
#require 'pry'; binding.pry |
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.
Don't forget to remove your commented out debug statements ;)
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.
Oops, sorry. Fixed.
What are peoples thoughts on disabling the Rubocop errors In any case, this PR does not introduce new linting errors. |
So apparently rubocop doesn't check templates. I called it on this file explicitly. Never mind. |
@iankronquist I think we should squash the most recent three commits (removing debug statements, updating warning messages, and fixing rubocop errors). You can either squash them into your first commit, or sometimes what we do is have a commit for addressing pull request feedback where you can just describe all the things you changed. But ultimately nothing in those commits is very interesting on its own, so it will make the git history a little easier for people to navigate in the future if we squash those. |
a25f157
to
0dca812
Compare
We should have the same standard on RuboCop as we have for puppet IMO. |
0dca812
to
0969c63
Compare
Squashed together. |
@hlindberg We are using the same rubocop standards as puppet for strings. There was just some confusion because we don't use rubocop to check anything in the templates directory due to the fact that it's full of .erb files. :) |
Okay, so I few suggestions. First, when I test I don't see file or line numbers, I see warnings like this:
I also think that for consistency, we should try to make the format of our warnings similar to the way YARD does things, the same warning from YARD looks like this:
The last thing that I think would be ideal (unless this proves to be way too complicated and involve a lot of monkey patching) is to figure out how to silence YARD's warnings about missing parameters. Due to the fact that puppet functions are just a little different from Ruby, YARD will issue warnings for For example with this puppet function:
I see these warnings:
|
0969c63
to
14701f4
Compare
|
reg 3. Can we perhaps fool yard into believing there is such a parameter? |
5e163c5
to
565b9ae
Compare
Not sure we can completely monkey patch away the yard behavior as it is of value when operating on Ruby code that is included in a module - helper classes etc. Is there some way we can make that conditional depending on if it is one of "our things" being processed or not? |
@hlindberg That feels kind of tricky because puppet functions (which is the issue in question at the moment) is Ruby code which is being processed via the Ruby parser. We do have our own handlers for puppet functions which inherit from @iankronquist What do you think? Did you see any info about code objects when you were in there with the debugger? |
306c88d
to
aa8b95a
Compare
Now with more tests! @hkenney @hlindberg r? |
I'm working on trying to figure out how to update strings tests so that they are not tied to rspec 2. That way existing tests and the tests in this PR can coexist. Stay tuned |
@@ -50,6 +50,7 @@ def check_required_features | |||
# For now, assume the remaining positional args are a list of manifest | |||
# and ruby files to parse. | |||
yard_args = (args.empty? ? MODULE_SOURCEFILES : args) | |||
class YARD::Logger; def progress(*args); end; end |
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.
break this up on multiple lines
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.
Actually this is for debugging purposes and should be removed entirely. It's gutting a method so that threads do not get in the way of debugging.
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.
ah ok - then it is better to have it as a one-liner :-) if useful later - comment it out and have a comment # For debugging, uncomment to .... or somesuch? I have used that in the parser in a place where it was difficult to remember where to add it back in when doing certain kinds of debugging. - just a 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.
👍 Seems like a good idea to me! I use this line often (I have it written on a sticky note)
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.
@iankronquist Could you go ahead and make this change? Just comment it out and leave a comment above explaining why it is useful for debugging (e.g. prevent threading so we can use the debugger)
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.
Fixed.
aa8b95a
to
b377424
Compare
Print the name of the parameter, the file, and the line number to stderr if the parameter name does not match the name specified in the docs. In order for this to be useful we need to present the user with the file name and line number of the relevant parameters. This information needs to be extracted from the code object and passed to the extract_param_details method.
Traverse the ruby AST to get method arguments and attach them to the code object. * Fixes spurious warnings issued by yard. * Obviates the need for ugly regex code in the templates to retrieve parameters from the source code.
Also comment out a statement which we frequently use for debugging which snuck in by accident.
b377424
to
d37e071
Compare
+1 on merging |
Override Yard logger on a per test basis, not globally. Replace one hack with another slightly less disgusting one.
(PDOC-37) Warn when documented name does not match declared name
A rude first attempt. Let's see how this goes.
For warnings we just print to stderr. Note that Yard does not print its warnings to stderr, which is a bit crude.
Note that this does not do any type checking. Presently, if I understand correctly, our handlers do not add any type information so we can't compare types with the comments.
Addresses PDOC-37