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
aio + docs/api: implement content checks #22759
aio + docs/api: implement content checks #22759
Conversation
You can preview 01b2a5e at https://pr22759-01b2a5e.ngbuilds.io/. |
* To creeate a rule that will only allow level 3 headings: | ||
* | ||
* ``` | ||
* const rule = createrNoMarkdownHeadingRule(1, 2, '4,'); |
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.
typo
You can preview 19e89ba at https://pr22759-19e89ba.ngbuilds.io/. |
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 about non-markdown headings (e.g. <h1>Haxx</h1>
)?
if (!disallowedHeadings.length) { | ||
disallowedHeadings.push('#{1,}'); | ||
} | ||
const regex = new RegExp(`^ ?(${disallowedHeadings.join('|')}) +.*$`, 'mg'); |
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 if there are 2+ leading whitespaces?
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, good question. According to the CommonMark spec:
The opening # character may be indented 0-3 spaces.
I will fix this.
* | ||
* The processor will run each rule function against each matching property of each matching doc. | ||
* | ||
* An example rule might look like: |
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.
"A totally made-up example..." 😛
* [property]: Array<(doc: Document, property: string, value: any) => string|undefined> | ||
* } | ||
* } | ||
*/ |
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.
💯
$runBefore: ['processing-docs'], | ||
$process(docs) { | ||
const errors = []; | ||
// Ensure that we have ruleFns for all regex rules |
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 sure what this comment refers to 😕
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.
Doh! From a previous incarnation of the algorithm, which I abandoned.
My view is that we let the authors override anything by using HTML directly. |
This processor will enable us to write rules about how the content should appear, such as: * no headings in markdown content * only one sentence per line * no single character parameter names * etc.
This content rule can check what markdown headings appear in content properties.
* No headings are allowed in `description` and `shortDescription` * Only heading level 3 is allowed in `usageNotes`
This rule can be used to ensure that properties contain a minimum number of characters.
19e89ba
to
97b8fec
Compare
You can preview d64e868 at https://pr22759-d64e868.ngbuilds.io/. |
@gkalpak PTAL |
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 can't tell from this code if this will results in warnings or errors, but since the build is green, I assume warnings. If that's the case then this LGTM.
@@ -0,0 +1,8 @@ | |||
module.exports = function createMinLengthRule(minLength) { | |||
minLength = minLength || 2; |
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 should consider being a bit more aggressive and require at least 3 or 4 characters. I can't think of any variables that should be less than 4 chars, but we should test and see. I suggest we start with 4 and if we find legit usecases for variable names of length 3 then we can decrease 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.
How about url
:-P This occurs "lots" of times.
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.
Others that occur in the current code:
p
req
fn
key
k
v
ctx
obj
id
el
cd
dir
c
cb
max
min
res
err
cdr
sw
I would say that setting the minimum size to 3 chars would be a reasonable compromise.
This content rule can check what markdown headings appear in content properties. PR Close #22759
* No headings are allowed in `description` and `shortDescription` * Only heading level 3 is allowed in `usageNotes` PR Close #22759
This rule can be used to ensure that properties contain a minimum number of characters. PR Close #22759
Yes we can set the |
This processor will enable us to write rules about how the content should appear, such as: * no headings in markdown content * only one sentence per line * no single character parameter names * etc. PR Close angular#22759
This content rule can check what markdown headings appear in content properties. PR Close angular#22759
…2759) * No headings are allowed in `description` and `shortDescription` * Only heading level 3 is allowed in `usageNotes` PR Close angular#22759
This rule can be used to ensure that properties contain a minimum number of characters. PR Close angular#22759
This processor will enable us to write rules about how the content should appear, such as: * no headings in markdown content * only one sentence per line * no single character parameter names * etc. PR Close angular#22759
This content rule can check what markdown headings appear in content properties. PR Close angular#22759
…2759) * No headings are allowed in `description` and `shortDescription` * Only heading level 3 is allowed in `usageNotes` PR Close angular#22759
This rule can be used to ensure that properties contain a minimum number of characters. PR Close angular#22759
This processor will enable us to write rules about how the content should appear, such as: * no headings in markdown content * only one sentence per line * no single character parameter names * etc. PR Close angular#22759
This content rule can check what markdown headings appear in content properties. PR Close angular#22759
…2759) * No headings are allowed in `description` and `shortDescription` * Only heading level 3 is allowed in `usageNotes` PR Close angular#22759
This rule can be used to ensure that properties contain a minimum number of characters. PR Close angular#22759
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR adds a new dgeni processor
checkContentRules
, which will enable us to write rules about how the content should appear. We then implement two actual rules:@description
blocks and only allowh3
headings in@usageNotes
blocksSince this produces a large number of errors the
checkContentRules.failOnContentErrors
is not set totrue
. But we can do this later once the documentation content has been cleaned up.Further we can add or adjust these rules going forward to ensure more documentation consistency.
Closes #22137
Closes #22682