node icon indicating copy to clipboard operation
node copied to clipboard

feat(doc): Add warning blocks to API docs

Open akuankka128 opened this issue 1 year ago • 1 comments

I think having just text warnings for potential vulnerabilities relating to the misuse of Node APIs isn't sufficient because they blend in too well. For example, in the documentation for fs.access(), readers might skip past the paragraph about potential race conditions when using the API to check if a file exists and the bold text saying "NOT RECOMMENDED." I suggest that warning blocks be added into the documentation to make it more obvious.

Before proposed change: Documentation before proposed change

After proposed change: Documentation after proposed change, showing an orange warning block with text

To achieve this, I simply added padding: 1rem, background: rgba(255, 79, 0, 0.5), and border-left: 6pt solid rgb(255, 79, 0) to the paragraph's style. Maybe something similar could be done to the "NOT RECOMMENDED" text too, or maybe the code should even be removed, because what is it there for, anyway? -- Showing the wrong way to be avoided? I don't know how helpful that actually is, so I don't have a strong opinion about it.

akuankka128 avatar Apr 29 '24 07:04 akuankka128

We already use <strong class="critical"> in various places. Maybe we can just rework that style a little bit.

tniessen avatar May 09 '24 11:05 tniessen

As mentioned in #52814, this feature should hopefully be added to the documentation redesign, I'm closing this issue, as this feature will (hopefully) be added. If you disagree, feel free to re-open.

avivkeller avatar May 11 '24 13:05 avivkeller