diff --git a/docs/manual/development.adoc b/docs/manual/development.adoc index 9be8e09..279d08b 100755 --- a/docs/manual/development.adoc +++ b/docs/manual/development.adoc @@ -7,7 +7,7 @@ [source,bash] ---- -git clone https://github.com/yourusername/asciidoc-linter.git +git clone https://github.com/docToolchain/asciidoc-linter.git cd asciidoc-linter ---- @@ -28,17 +28,45 @@ asciidoc-linter/ ├── asciidoc_linter/ # Main package │ ├── __init__.py │ ├── cli.py # Command line interface -│ ├── rules.py # Base rule classes -│ ├── heading_rules.py # Heading-specific rules +│ ├── rules/ # Rule implementations +│ │ ├── __init__.py +│ │ ├── base.py # Base classes for rules +│ │ ├── heading_rules.py +│ │ ├── block_rules.py +│ │ ├── whitespace_rules.py +│ │ └── image_rules.py │ ├── parser.py # AsciiDoc parser │ └── reporter.py # Output formatters ├── tests/ # Test files -│ └── rules/ -│ └── test_heading_rules.py +│ └── rules/ # Rule-specific tests ├── docs/ # Documentation └── README.adoc ---- +== Current Implementation Status + +=== Implemented Features + +* Core rule engine with base classes +* Rule implementations: +** Heading rules (hierarchy, format, multiple top-level) +** Block rules (termination, spacing) +** Whitespace rules (spacing, formatting) +** Image rules (attributes, file verification) +* Basic command line interface +* Multiple output formats (console, JSON, HTML) +* Comprehensive test suite + +=== Planned Features + +* Configuration system (YAML/JSON) +** Rule enabling/disabling +** Severity customization +** Custom rule parameters +* Additional rule types +* IDE integration +* Git hooks + == Adding New Rules === Rule Implementation Steps @@ -47,12 +75,17 @@ asciidoc-linter/ + [source,python] ---- -from .rules import Rule, Finding, Severity, Position +from .base import Rule, Finding, Severity, Position class MyNewRule(Rule): + """ + RULE_ID: Short description. + Detailed explanation of what the rule checks. + """ + def __init__(self): super().__init__() - self.id = "NEW001" + self.id = "RULE_ID" @property def description(self) -> str: @@ -64,7 +97,26 @@ class MyNewRule(Rule): return findings ---- -2. Add tests for the rule +2. Add tests for the rule: ++ +[source,python] +---- +class TestMyNewRule(unittest.TestCase): + def setUp(self): + self.rule = MyNewRule() + + def test_valid_case(self): + content = "Valid content" + findings = self.rule.check(content) + self.assertEqual(len(findings), 0) + + def test_invalid_case(self): + content = "Invalid content" + findings = self.rule.check(content) + self.assertEqual(len(findings), 1) + self.assertEqual(findings[0].rule_id, "RULE_ID") +---- + 3. Register the rule in the linter 4. Update documentation @@ -74,6 +126,8 @@ class MyNewRule(Rule): * Meaningful error messages * Proper severity levels * Contextual information in findings +* Comprehensive test cases +* Documentation with examples == Code Style @@ -81,15 +135,42 @@ class MyNewRule(Rule): * Follow PEP 8 * Use type hints -* Write docstrings -* Keep functions focused +* Write docstrings (Google style) +* Keep functions focused and testable +* Maximum line length: 100 characters +* Use meaningful variable names === Documentation Guidelines * Use AsciiDoc format -* Include examples +* Include examples for all features * Explain error messages * Document configuration options +* Keep README.adoc up to date + +== Testing + +=== Running Tests + +[source,bash] +---- +# Run all tests +python run_tests.py + +# Run specific test file +python -m unittest tests/rules/test_heading_rules.py + +# Run specific test case +python -m unittest tests.rules.test_heading_rules.TestHeadingHierarchyRule +---- + +=== Test Guidelines + +* Write tests for all new features +* Include both positive and negative test cases +* Test edge cases +* Maintain high test coverage +* Use meaningful test names == Pull Request Process @@ -97,13 +178,20 @@ class MyNewRule(Rule): 2. Implement changes 3. Add/update tests 4. Update documentation -5. Submit PR +5. Run full test suite +6. Submit PR == Release Process -1. Update version number +1. Update version number in __init__.py 2. Update changelog 3. Run full test suite 4. Create release notes 5. Tag release -6. Build and publish \ No newline at end of file +6. Build and publish + +== Getting Help + +* GitHub Issues: https://github.com/docToolchain/asciidoc-linter/issues +* Project Wiki: https://github.com/docToolchain/asciidoc-linter/wiki +* docToolchain Community: https://doctoolchain.org/community diff --git a/docs/manual/introduction.adoc b/docs/manual/introduction.adoc index 5c5f1d7..b37e292 100755 --- a/docs/manual/introduction.adoc +++ b/docs/manual/introduction.adoc @@ -5,21 +5,34 @@ AsciiDoc Linter is a Python-based tool designed to help maintain high-quality AsciiDoc documentation. It checks your AsciiDoc files for common issues and style violations, helping teams maintain consistent documentation standards. +As part of the docToolchain project (https://doctoolchain.org), it integrates well with existing documentation workflows. + == Key Features * Heading structure validation -* Format checking -* Style consistency enforcement -* Multiple output formats -* Configurable rules +** Proper hierarchy (no skipped levels) +** Consistent formatting +** Single top-level heading +* Block validation +** Proper block termination +** Consistent spacing +* Whitespace consistency +** Line spacing +** List formatting +** Tab detection +* Image validation +** Attribute checking +** File existence verification +* Multiple output formats (console, JSON, HTML) == Project Goals -* Improve documentation quality -* Enforce consistent styling -* Reduce review effort -* Catch common mistakes early -* Support documentation as code +* Improve documentation quality through automated checks +* Enforce consistent styling across documentation +* Reduce manual review effort +* Catch common mistakes early in the documentation process +* Support documentation as code practices +* Integrate with existing documentation toolchains == Technical Overview @@ -46,19 +59,54 @@ AsciiDoc Linter is a Python-based tool designed to help maintain high-quality As === Prerequisites * Python 3.8 or higher -* pip (Python package manager) -* Git (for development) +* Git (for installation) + +=== Installation -=== Quick Start +[NOTE] +==== +Direct installation via pip is planned for future releases. Currently, installation is done via git clone. +==== [source,bash] ---- +# Clone the repository +git clone https://github.com/docToolchain/asciidoc-linter.git + +# Navigate to the project directory +cd asciidoc-linter + # Install the package -pip install asciidoc-linter +pip install . +---- + +=== Basic Usage -# Run a basic check -asciidoc-lint your-document.adoc +[source,bash] +---- +# Check a single file +asciidoc-lint document.adoc + +# Check multiple files +asciidoc-lint doc1.adoc doc2.adoc # Get help asciidoc-lint --help ----- \ No newline at end of file +---- + +== Current Status + +=== Implemented Features + +* Core linting engine +* Basic rule set (headings, blocks, whitespace, images) +* Command-line interface +* Multiple output formats + +=== Planned Features + +* Configuration system (YAML/JSON) +* Additional rule sets (tables, links, cross-references) +* Direct installation via pip +* IDE integration +* Git pre-commit hooks diff --git a/docs/manual/rules.adoc b/docs/manual/rules.adoc index a1f4196..73f81ae 100755 --- a/docs/manual/rules.adoc +++ b/docs/manual/rules.adoc @@ -1,23 +1,197 @@ -# rules.adoc - Documentation of all linter rules +// rules.adoc - Documentation of all linter rules += AsciiDoc Linter Rules -[Previous content remains unchanged until "Planned Rules" section] +== Heading Rules + +=== HEAD001: Heading Hierarchy + +Ensures proper heading level incrementation (no skipped levels). + +==== Description + +This rule checks that heading levels are not skipped. For example, you cannot go from a level 1 heading (=) directly to a level 3 heading (===) without having a level 2 heading (==) in between. + +==== Examples + +.Valid Heading Hierarchy +[source,asciidoc] +---- += Document Title (Level 1) + +== Section (Level 2) + +=== Subsection (Level 3) + +== Another Section (Level 2) +---- + +.Invalid Heading Hierarchy +[source,asciidoc] +---- += Document Title (Level 1) + +=== Subsection (Level 3) // Error: Skipped Level 2 +---- + +=== HEAD002: Heading Format + +Ensures proper heading format (spacing and capitalization). + +==== Description + +This rule checks two aspects of heading format: +1. There must be a space after the = characters +2. The heading text should start with an uppercase letter + +==== Examples + +.Valid Heading Format +[source,asciidoc] +---- += Document Title +== Section Title +=== Subsection Title +---- + +.Invalid Heading Format +[source,asciidoc] +---- +=Document Title // Error: No space after = +== section title // Warning: Starts with lowercase +---- + +=== HEAD003: Multiple Top Level Headings + +Ensures document has only one top-level heading. + +==== Description + +This rule checks that there is only one level 1 heading (=) in the document. Multiple top-level headings can indicate structural problems or accidentally split documents. + +==== Examples + +.Valid Single Top Level +[source,asciidoc] +---- += Main Document Title + +== Section One +== Section Two +---- + +.Invalid Multiple Top Level +[source,asciidoc] +---- += First Title + +== Section One + += Second Title // Error: Multiple top-level headings +---- + +== Block Rules + +=== BLOCK001: Unterminated Blocks + +Checks for blocks that are not properly terminated. + +==== Description + +This rule ensures that all block delimiters are properly paired. Each opening delimiter must have a matching closing delimiter. + +==== Supported Block Types + +* Listing blocks (----) +* Example blocks (====) +* Sidebar blocks (****) +* Literal blocks (....) +* Quote blocks (____) +* Table blocks (|===) +* Comment blocks (////) +* Passthrough blocks (++++). + +==== Examples + +.Valid Block Termination +[source,asciidoc] +---- +[source,python] +---- +def hello(): + print("Hello, World!") +---- + +.Example Block +==== +Some example content +==== +---- + +.Invalid Block Termination +[source,asciidoc] +---- +[source,python] +---- +def hello(): + print("Hello, World!") +// Error: Missing closing ---- + +.Example Block +==== +Some example content +// Error: Missing closing ==== +---- + +=== BLOCK002: Block Spacing + +Verifies proper spacing around blocks. + +==== Description + +This rule checks that blocks are properly separated from surrounding content with blank lines, improving readability. + +==== Examples + +.Valid Block Spacing +[source,asciidoc] +---- +Some text before the block. + +---- +Block content +---- + +Some text after the block. +---- + +.Invalid Block Spacing +[source,asciidoc] +---- +Some text before the block. +---- // Warning: No blank line before block +Block content +---- +Some text after the block. // Warning: No blank line after block +---- == Whitespace Rules === WS001: Whitespace Usage -Ensures proper whitespace usage throughout the document. This rule helps maintain consistent formatting and improves readability. +Ensures proper whitespace usage throughout the document. ==== Checks Performed -1. *Consecutive Empty Lines*: No more than one consecutive empty line allowed +1. *Consecutive Empty Lines*: No more than one consecutive empty line 2. *List Marker Spacing*: Proper space after list markers (*, -, .) 3. *Admonition Block Spacing*: Blank line before admonition blocks 4. *Trailing Whitespace*: No trailing spaces at end of lines 5. *Tab Usage*: No tabs (use spaces instead) 6. *Section Title Spacing*: Blank lines around section titles -.Valid Examples +==== Examples + +.Valid Whitespace Usage [source,asciidoc] ---- = Document Title @@ -32,7 +206,7 @@ NOTE: This is a note. Some text here. ---- -.Invalid Examples +.Invalid Whitespace Usage [source,asciidoc] ---- = Document Title @@ -46,22 +220,69 @@ Some text here // Trailing spaces Extra blank line // Too many blank lines ---- -.Configuration Options -[cols="1,1,2"] -|=== -|Option |Default |Description +== Image Rules + +=== IMG001: Image Attributes + +Verifies image attributes and file references. + +==== Description + +This rule checks: +1. All images have alt text +2. Referenced local images exist +3. Block images have titles +4. Image attributes are properly formatted + +==== Examples + +.Valid Image Usage +[source,asciidoc] +---- +// Inline image with alt text +image:icon.png[Icon] + +// Block image with title and alt text +.Figure 1: System Architecture +image::diagram.png[Architecture Diagram] + +// External image with alt text +image:https://example.com/img.png[Example Image] +---- + +.Invalid Image Usage +[source,asciidoc] +---- +// Missing alt text +image:icon.png[] + +// Missing title for block image +image::diagram.png[Diagram] + +// Non-existent local file +image::missing.png[Missing Image] +---- + +== Planned Rules + +=== TABLE001: Table Formatting (Planned) + +Will check table formatting consistency: +* Column alignment +* Header row presence +* Cell content formatting + +=== LINK001: Link Verification (Planned) -|enabled -|true -|Enable/disable rule +Will verify: +* Internal cross-references +* External link validity +* Anchor definitions -|severity -|warning -|Rule severity level +=== FMT001: Format Consistency (Planned) -|max_empty_lines -|1 -|Maximum number of consecutive empty lines -|=== +Will check: +* Consistent emphasis style +* List formatting +* Admonition usage -[Previous content continues from "Planned Rules" section] \ No newline at end of file