Skip to content

[RFC]: add remark plugin(s) for ensuring that each <section> tag has a matching closing tag #49

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

Open
kgryte opened this issue Mar 8, 2025 · 2 comments
Assignees
Labels
🤖 AI Allowed to use AI. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. estimate: 2-4hrs Task which should take between 2 to 4 hours. Feature Task to add a new feature.

Comments

@kgryte
Copy link
Member

kgryte commented Mar 8, 2025

In our README files, we use HTML markup to demarcate sections. This markup is useful in two ways: (1) it allows us to more readily perform transformations on Markdown content, as we can often use regexp which explicitly target opening <section> tags with a desired class and a corresponding comment and (2) it allows straightforward publishing to the documentation website.

It has, however, become a common occurrence for our READMEs to become "corrupted" with new contributors failing to insert closing tags or inserting content where it shouldn't be.

This RFC proposes adding linting to enforce both valid HTML markup and that sections are properly inserted.

  1. At a bare minimum, each opening <section> tag should have a corresponding </section>. Meaning, no orphaned <section> tags.

  2. At the next level of complexity, each opening <section class="foo"> tag should have a corresponding <!-- /.foo --> closing comment.

  3. At the highest level of complexity, we have lint rules which enforce expected nesting. Meaning, e.g., a C section should have usage, examples, notes, and maybe a couple of other sections, but never a "related packages" section. Or in other words, certain sections should always be at the same level, such as usage, notes, examples, C, references, related, and links.

While the first two lint capabilities can be considered stdlib agnostic, the last capability is heavily specific to stdlib.

Whether each capability should be a separate rule OR everything should be combined into a single rule is up to the implementor. At the least, 1-2 can likely be combined. 3, however, may be best left to a separate rule.

That said, (3) should also be straightforward to implement in its own right. Namely, visit each HTML node. Resolve the class, if present. Map each new section to an object. When you open a new class, create a new object. When you close a section, close the object. The result may be something like

[
  { "name": "intro" , "children": [...] },
  { "name": "usage", "children": [...] },
  { "name": "examples", "children": [...] },
  { "name": "c", "children": [
    { "name": "intro", "children": [...] },
    { "name": "usage", "children": [...] },
    { "name": "notes", "children": [... ] },
    { "name": "examples", "children": [...] }
  },
  { "name": "references", "children": [...] },
  { "name": "related", "children": [... ] },
  { "name": "links", "children": [...] }
]

Once the HTML structure is derived, it should be possible to apply validation, either via a JSON schema or programmatically.

Time with AI: 2h 30min
TIme without AI: 3h

Prior Task Exposure: 3
External Resource Needs: 2

@kgryte kgryte added difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. Feature Task to add a new feature. labels Mar 8, 2025
@Planeshifter Planeshifter added the estimate: 2-4hrs Task which should take between 2 to 4 hours. label Mar 15, 2025
@naterush naterush added the 🤖 AI Allowed to use AI. label Mar 15, 2025
@Planeshifter
Copy link
Member

Planeshifter commented Apr 20, 2025

Time to initial completion: 2h 24min.

Loom recordings:
https://www.loom.com/share/0d49bdd1f70a4ba1bf99ed6452be1cce?sid=bbac438a-7a44-4c4b-9048-c308b7bec452
https://www.loom.com/share/5a44bc3e46f9443e859dc73e606d928f?sid=205b82c5-c783-414a-b8fe-d0bd5f8ebc32
https://www.loom.com/share/cb3fe1a5ea7e40e6aa23676dcb4b3841?sid=b78b0349-022b-4bc6-984e-702d09a1e3d0
https://www.loom.com/share/ade6d88c91834699aad578006f1b144d?sid=b7affa0d-2e2e-4207-8d68-f9f1148bba9f

Notes:
The agent loop worked well once instructed to add debug instructions to resolve bugs in the initial implementation. Generated code adhered overall to stdlib code conventions, but some edits will have to be made to bring the respective PRs over the finish line (e.g., variable where not moved to the correct scopes and functions need to be moved to module or outer scopes).

@Planeshifter
Copy link
Member

kgryte added a commit to stdlib-js/stdlib that referenced this issue Apr 25, 2025
PR-URL: #6156
Ref: stdlib-js/metr-issue-tracker#49
Co-authored-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Athan Reines <kgryte@gmail.com> 
Co-authored-by: stdlib-bot <noreply@stdlib.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 AI Allowed to use AI. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. estimate: 2-4hrs Task which should take between 2 to 4 hours. Feature Task to add a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants