-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
modify yardopts parsing to ignore hash and c-style comments #1070
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -510,10 +510,23 @@ def foo; end | |
optsdata = String.new("foo bar") | ||
expect(optsdata).to receive(:shell_split) | ||
expect(File).to receive(:read_binary).with("test").and_return(optsdata) | ||
allow(optsdata).to receive(:gsub).and_return(optsdata) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this mocked? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
@yardoc.options_file = "test" | ||
@yardoc.run | ||
end | ||
|
||
it "ignores .yardopts tokens that are comments" do | ||
optsdata = String.new("--one-file --locale es # --locale en\n// --title not_my_title") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test should not pass, see above. Having "#" as an argument to YARD is completely valid. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another bunch of completely valid examples:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the "handle comments ending a line" functionality as an edge case at the last minute. Didn't think about these -- of course, you're right. Happy to not have this. |
||
expect(File).to receive(:read_binary).with("test").and_return(optsdata) | ||
@yardoc.options_file = "test" | ||
@yardoc.run | ||
|
||
expect(@yardoc.options.onefile).to be_truthy | ||
expect(@yardoc.options.locale).to eq('es') | ||
expect(@yardoc.options.title).not_to eq('not_my_title') | ||
expect(@yardoc.options.serializer.options) | ||
end | ||
|
||
it "allows opts specified in command line to override yardopts file" do | ||
expect(File).to receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH") | ||
@yardoc.run("-o", "MYPATH", "FILE") | ||
|
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.
We're going to need a requirement that comments start at the beginning of the line (incl. optional whitespace), otherwise a valid option like the following will not work:
Or even (awkward but completely valid):
Unfortunately this would be a hard requirement.
I would recommend tests for these edge cases too.
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.
I'm completely for the constraint that this only support comments starting at the beginning of the line.
I'm happy to add more tests -- wanted to get your temperature on this first.