Skip to content

build: add remark plugin to validate expected HTML sections #6156

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
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

Planeshifter
Copy link
Member

Description

What is the purpose of this pull request?

This pull request:

  • adds a remark plugin to ensure that README.md files have the expected HTML <section> tag structure as mandated by stdlib conventions.

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Tools Issue or pull request related to project tooling. Needs Review A pull request which needs code review. labels Mar 18, 2025
@Planeshifter
Copy link
Member Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Mar 18, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Mar 18, 2025
@Planeshifter Planeshifter requested a review from kgryte March 18, 2025 15:45
@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Apr 16, 2025
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@Planeshifter Planeshifter requested a review from kgryte April 20, 2025 21:42
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Apr 20, 2025
Signed-off-by: Athan <kgryte@gmail.com>
var className;

// Check if this is a section start tag:
sectionMatch = RE_SECTION_START.exec( node.value );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question regarding the use of exec.

Comment on lines +174 to +178
else if ( RE_SECTION_END.test( node.value ) ) {
if ( sectionStack.length > 0 ) {
sectionStack.pop();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else if ( RE_SECTION_END.test( node.value ) ) {
if ( sectionStack.length > 0 ) {
sectionStack.pop();
}
}
else if ( RE_SECTION_END.test( node.value ) && sectionStack.length > 0 ) {
sectionStack.pop();
}

You can refactor to avoid an extra level of nesting.

return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
}
if ( hasOwnProp( options, 'schema' ) ) {
if ( !isObject( options.schema ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly weak check, as I could pass in options.schema = { 'foo': 'bar', 'required': null } and this validation test would pass.

t.fail( err.message );
}
t.strictEqual( file.messages.length, 1, 'has one error for invalid asin fixture' );
t.strictEqual( file.messages[0].reason.includes('Missing required sections in "c" section: `usage`'), true, 'error identifies the missing C usage section' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor to avoid use of includes here and below. Also, spacing.

t.fail( err.message );
}
t.strictEqual( file.messages.length, 1, 'has one error for fixture missing a required root section' );
t.strictEqual( file.messages[0].reason.includes('Missing required root-level sections: `usage`'), true, 'error identifies the missing section' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.

t.fail( err.message );
}
t.strictEqual( file.messages.length, 1, 'has one error for fixture with an incomplete C section' );
t.strictEqual( file.messages[0].reason.includes('Missing required sections in "c" section: `usage`, `examples`'), true, 'error identifies the missing C sections' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.

t.fail( err.message );
}
t.strictEqual( file.messages.length, 1, 'has correct number of errors with custom schema' );
t.strictEqual( file.messages[0].reason.includes('usage') && file.messages[0].reason.includes('related'), true, 'error identifies both missing sections' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.

Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left an initial round of comments.

@kgryte kgryte removed the Needs Review A pull request which needs code review. label Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Changes Pull request which needs changes before being merged. Tools Issue or pull request related to project tooling.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants