-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix syntax errors in QL comments #8952
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
@@ -53,7 +53,7 @@ import javascript | |||
* | |||
* /** | |||
* * @param {!Object} obj | |||
* * @return {!Array<string>} | |||
* * @return {!Array<string>} |
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.
These are wrapped in <pre>...</pre>
, so are these changes necessary? Changing <
to <
hurts readability.
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.
Reserved characters such as <
and >
still needs to be escaped using their HTML entity. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
You can see that @return {!Array<string>}
currently shows up as @return {!Array}
because the browser treats <string>
as an unknown element.
https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Externs.qll/type.Externs$ExternalDecl.html
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.
Could we replace the <pre>
with triple backquotes instead?
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.
You could, but the */
in the next line would stop working.
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.
See - I have no idea what entity number 47 is - I had to look that up, that's pretty poor readability. Luckily the obvious answer is just to replace /
with /
.
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.
Hmm, right, I see why the entity is used for /
. But the <pre>
isn't really a good solution - it doesn't appear to render correctly in VSCode (on predicate mouse-over).
Most of the changes look fine, so mostly no objections from me. Except for the |
* - Line 16: There is no static target (delegate call) but the delegate `i => { }` (line | ||
* 20) is a run-time target. | ||
* - Line 16: There is no static target (delegate call) but the delegate `i => { }` | ||
* (line 20) is a run-time target. |
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 don't mind this change, but hopefully it is not needed to generete proper QL doc?
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.
It actually is needed. Here is what the rendered documentation currently looks like, without this fix:
https://codeql.github.com/codeql-standard-libraries/csharp/semmle/code/csharp/exprs/Call.qll/predicate.Call$Call$getARuntimeTarget.0.html
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.
Any explanation why it renders that way? Is it a rendering bug?
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 think that is because 20)
is interpreted as a numbered list item starting at number 20.
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, that makes a bit more sense then. A markdown gotcha.
@@ -1,6 +1,6 @@ | |||
/** | |||
* @name Incorrect type parameter name in documentation | |||
* @description The type parameter name given in a '<typeparam>' tag does not exist. Rename the parameter or | |||
* @description The type parameter name given in a `<typeparam>` tag does not exist. Rename the parameter or |
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.
If this is the new way of doing things, we should update the comment Any code elements included in the description should be enclosed in single quotes
(https://github.com/github/codeql/blob/main/docs/query-metadata-style-guide.md?plain=1#L63), as well as the example.
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 should clarify that this is not a style change but a rendering fix. Here is what the documentation currently looks like:
https://codeql.github.com/codeql-standard-libraries/csharp/Documentation/XmldocExtraTypeParam.ql/module.XmldocExtraTypeParam.html
QL comments can include Markdown and HTML, so the <
and >
characters need to be escaped, either by putting them in Markdown code format (the approach I took here) or by replacing them with <
and >
. I can switch it to the second approach if that is more style-compliant.
I agree that using Markdown backquotes for code elements seems sensible, but that should probably be a separate discussion.
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.
this is not a style change but a rendering fix
No, it's both a style change and a rendering fix.
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.
C/C++ 👍
I think it is a problem that we allow html in our qldoc, we should restrict ourselves to markdown and then we wouldn't need such readability-impeding changes like writing |
I intended this PR to be a quick low-effort fix for QL documentation that is already broken. Unfortunately, I really do not have more time to devote to this PR or the issue of broken documentation, so I will just have to leave this PR as-is. I am sure that you all as the owners of the documentation will be able to resolve the open questions and find the best way to address both the immediate and the long-term issues. Thank you! 🙏 |
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.
JS 👍
The change in Externs.qll
makes it slightly harder to read the source code.
But it seems like the best solution, because the rendered documentation should definitely render correctly.
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.
As commented above.
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.
The change in javascript/ql/lib/semmle/javascript/Externs.qll
is unfortunate and makes me want to abolish html entirely from our qldoc, but currently I can't think of a way to render */
inside a triple-backtick code block. Note that the <pre>
block doesn't render correctly in VSCode, so going for a markdown solution would be preferable, but I'll revert my position on whether just to merge this PR for now.
This PR fixes QL comments used to generate QL documentation. They are mostly about back-quoting angle brackets so that they are property escaped in the HTML output.