-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add section validation warnings for recommended manuscript sections #275
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,139 @@ | ||||||
| """Section validator for checking recommended manuscript sections. | ||||||
|
|
||||||
| This validator checks if manuscripts include important sections that are | ||||||
| commonly required by journals, such as: | ||||||
| - Data Availability | ||||||
| - Code Availability | ||||||
| - Author Contributions | ||||||
| - Acknowledgements | ||||||
| - Funding | ||||||
| - Competing Interests | ||||||
|
|
||||||
| Missing sections generate warnings (not errors) to help authors ensure | ||||||
| their manuscript is complete before submission. | ||||||
| """ | ||||||
|
|
||||||
| import re | ||||||
|
|
||||||
| from ..utils.file_helpers import find_manuscript_md | ||||||
| from .base_validator import BaseValidator, ValidationError, ValidationLevel, ValidationResult | ||||||
|
|
||||||
|
|
||||||
| class SectionValidator(BaseValidator): | ||||||
| """Validator for checking recommended manuscript sections.""" | ||||||
|
|
||||||
| # Required sections that should generate warnings if missing | ||||||
| RECOMMENDED_SECTIONS = { | ||||||
| "data availability": { | ||||||
| "patterns": [ | ||||||
| r"##\s+Data\s+Availability", | ||||||
| r"##\s+Data\s+and\s+Code\s+Availability", | ||||||
| ], | ||||||
| "suggestion": "Add a '## Data Availability' section describing where your data can be accessed", | ||||||
| }, | ||||||
| "code availability": { | ||||||
| "patterns": [ | ||||||
| r"##\s+Code\s+Availability", | ||||||
| r"##\s+Data\s+and\s+Code\s+Availability", | ||||||
| r"##\s+Software\s+Availability", | ||||||
| ], | ||||||
| "suggestion": "Add a '## Code Availability' section with links to code repositories", | ||||||
| }, | ||||||
| "author contributions": { | ||||||
| "patterns": [ | ||||||
| r"##\s+Author\s+Contributions?", | ||||||
| r"##\s+Contributions?", | ||||||
|
||||||
| r"##\s+Contributions?", |
Copilot
AI
Dec 24, 2025
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 Path object returned by find_manuscript_md should be converted to a string before passing to file_path parameter. The ValidationError.file_path is typed as str | None, but find_manuscript_md returns a Path object. For consistency with other validators and proper type handling, convert the Path to string using str().
Copilot
AI
Dec 24, 2025
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 Path object returned by find_manuscript_md should be converted to a string before passing to file_path parameter. The ValidationError.file_path is typed as str | None, and should match the expected type. Convert using str(manuscript_file).
| file_path=manuscript_file, | |
| file_path=str(manuscript_file), |
Copilot
AI
Dec 24, 2025
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 new SectionValidator lacks test coverage. The repository has comprehensive test coverage for other validators (see tests/unit/test_validators.py), and this new validator should have corresponding tests to verify pattern matching, warning generation, and edge cases like missing files or combined sections.
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.
Comment states "Required sections" but the constant is named "RECOMMENDED_SECTIONS". The comment should say "Recommended sections" to match the variable name and the actual behavior (warnings, not errors).