-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Generic/IncrementDecrementSpacing: add XML documentation #287
Generic/IncrementDecrementSpacing: add XML documentation #287
Conversation
b0e3be5
to
39755ea
Compare
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.
Hi @rodrigoprimo, thanks for this PR.
I wonder if it would make sense to simplify these docs to just one standard block and one set of code samples dealing with both pre- as well as post-in/decrement ?
Was there a particular reason to split this into two standards ? After all, the rule is the same "no space between the increment/decrement operator and the "variable" it applies to", doesn't really matter whether it's pre or post in/decrement.
I also wonder if the highlighting via the <em>
tags could be made more meaningful. Would it make sense to include the operator in the tags ? and the operator + whitespace for the invalid cases ?
src/Standards/Generic/Docs/WhiteSpace/IncrementDecrementSpacingStandard.xml
Outdated
Show resolved
Hide resolved
I was more inclined to use a single block, but I was a bit unsure, so I opted to follow what is recommended in the documentation and created one block per error/warning. I pushed a new commit combining the two blocks into one.
In my opinion, it is better to leave just the whitespaces or the "point" between the variable and the operator in the Could you please elaborate on why highlighting the operator would make the On a side note, the guide on how to write sniff documentation mentions that the HTML and Markdown generators use the I tested with the following command:
|
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.
Thanks for the update. A few more grammar fixes to go and this is ready for merge.
In the HTML version, this "point" is highlighted, and to me, it is clear that it is marking the place where the sniff is checking
Fair point. Let's leave the <em>
tags as they are now.
I don't see anything highlighted when I use the Markdown generator. Is this a bug, or should the documentation be updated?
Might well be a bug. I haven't really looked at that class before.
Then again, if generating in pure markdown - how would you highlight something within a code sample ?
The markdown specs don't really allow for that, other than via a mix of Markdown and HTML, so I suspect the documentation should be updated, not the class.
$obj->prop<em></em>--; | ||
]]> | ||
</code> | ||
<code title="Invalid: One or more whitespaces between variables and increment/decrement operators."> |
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.
"whitespaces" is not a word.
I think either one of the following could work:
- "One or more whitespace characters between..."
- "Whitespace between..."
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.
Ops, I didn't know that. Thanks!
I pushed a new commit, replacing the three instances where I used "whitespaces".
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: No whitespaces between variables and increment/decrement operators."> |
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.
<code title="Valid: No whitespaces between variables and increment/decrement operators."> | |
<code title="Valid: No whitespace between variables and increment/decrement operators."> |
<documentation title="Increment Decrement Spacing"> | ||
<standard> | ||
<![CDATA[ | ||
There should be no whitespaces between variables and increment/decrement operators. |
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.
There should be no whitespaces between variables and increment/decrement operators. | |
There should be no whitespace between variables and increment/decrement operators. |
I haven't checked the class that generates the Markdown documentation. I don't know if it changes anything, but I noticed that it is already mixing Markdown and HTML. Also, I don't know if and where the Markdown documentation is used. I'm also inclined to think that we should just update the documentation for now. Happy to do it if you would like. |
I've included that change in PR #304 |
The Markdown generator was added in squizlabs/PHP_CodeSniffer#381. The generator output isn't used by PHPCS itself at this time, but, aside from direct help via CLI, the HTML and Markdown output can be added to a website or wiki for a (project) coding standard. To me, that's the use-case for those generators. HTML can be used in Markdown, it is valid, but if the output becomes largely HTML, then I don't see why there should be a second (separate) generator for Markdown, so for now, I'm inclined to leave it alone. At a future point in time, I'd like to have a think about adding info related to public properties which can be set on a sniff to the docs and adding the possibility of adding links (like to the official PSR12 docs for the PSR12 sniffs) to docs. First priority regarding the docs now, is getting the docs for each sniff in place and there is still enough work to do there. Does that make sense ? |
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.
Thanks @rodrigoprimo. LGTM.
I did notice a tab had creeped into one of the code samples, I'll fix that up when I rebase the PR before merging it.
fe99ac5
to
6b358ed
Compare
* Generic/IncrementDecrementSpacing: add XML documentation
Description
This PR adds the XML documentation for the Generic.WhiteSpace.IncrementDecrementSpacing sniff.
Suggested changelog entry
Add XML documentation for the Generic.WhiteSpace.IncrementDecrementSpacing sniff.
Related issues/external references
Part of #148
Types of changes
PR checklist