Skip to content

Commit

Permalink
implemented further rules
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmueller committed Nov 27, 2024
1 parent 2fc918d commit 4c845f9
Show file tree
Hide file tree
Showing 28 changed files with 1,230 additions and 672 deletions.
Binary file modified .coverage
Binary file not shown.
48 changes: 33 additions & 15 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
image:https://img.shields.io/badge/license-MIT-blue.svg[License: MIT, link=https://opensource.org/licenses/MIT]
image:https://img.shields.io/badge/python-3.8+-blue.svg[Python Version]

A Python-based linter for AsciiDoc files that helps maintain consistent documentation quality and style.
A Python-based linter for AsciiDoc files that helps maintain consistent documentation quality and style. Part of the docToolchain project.

== About

AsciiDoc Linter is a command-line tool that checks your AsciiDoc files for common issues and style violations. It helps maintain consistent documentation by enforcing rules for heading structure, formatting, and more.
AsciiDoc Linter is a command-line tool that checks your AsciiDoc files for common issues and style violations. It helps maintain consistent documentation by enforcing rules for heading structure, formatting, whitespace, and image usage.

[NOTE]
====
This project was developed with the assistance of an AI language model (GPT-4) as part of an experiment in AI-assisted development. The AI helped design the architecture, implement the code, and create the documentation.
This project is part of docToolchain (https://doctoolchain.org), a collection of documentation tools and best practices.
====

== Features
Expand All @@ -28,7 +28,7 @@ This project was developed with the assistance of an AI language model (GPT-4) a
|Rule ID |Description |Severity

|HEAD001
|Check for proper heading incrementation (no skipping levels)
|Check for proper heading hierarchy (no skipping levels)
|ERROR

|HEAD002
Expand All @@ -46,13 +46,19 @@ This project was developed with the assistance of an AI language model (GPT-4) a
|BLOCK002
|Verify proper spacing around blocks
|WARNING

|WS001
|Check whitespace usage (blank lines, list markers, tabs)
|WARNING

|IMG001
|Verify image attributes and file references
|WARNING/ERROR
|===

=== Planned Rules

* WS001: Blank lines around headers and blocks
* TABLE001: Table formatting consistency
* IMG001: Image alt text presence
* LINK001: Broken internal references
* FMT001: Markdown-compatible styles detection

Expand All @@ -61,7 +67,7 @@ This project was developed with the assistance of an AI language model (GPT-4) a
[source,bash]
----
# Clone the repository
git clone https://github.com/yourusername/asciidoc-linter.git
git clone https://github.com/docToolchain/asciidoc-linter.git
# Navigate to the project directory
cd asciidoc-linter
Expand Down Expand Up @@ -114,6 +120,9 @@ WARNING: Block should be preceded by a blank line (line 67)
ERROR: Multiple top-level headings found (line 30)
First heading at line 1: 'Document Title'
WARNING: Missing alt text for image: diagram.png (line 80)
image::diagram.png[]
----

== Development
Expand All @@ -137,15 +146,21 @@ asciidoc-linter/
├── asciidoc_linter/
│ ├── __init__.py
│ ├── cli.py
│ ├── rules.py
│ ├── heading_rules.py
│ ├── block_rules.py
│ ├── rules/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── heading_rules.py
│ │ ├── block_rules.py
│ │ ├── whitespace_rules.py
│ │ └── image_rules.py
│ ├── parser.py
│ └── reporter.py
├── tests/
│ └── rules/
│ ├── test_heading_rules.py
│ └── test_block_rules.py
│ ├── test_block_rules.py
│ ├── test_whitespace_rules.py
│ └── test_image_rules.py
├── docs/
│ ├── requirements.adoc
│ └── block_rules.adoc
Expand All @@ -170,7 +185,7 @@ This project is licensed under the MIT License - see the LICENSE file for detail

== Acknowledgments

* This project was developed with the assistance of GPT-4, demonstrating the potential of AI-assisted development
* Part of the docToolchain project (https://doctoolchain.org)
* Inspired by various linting tools and the need for better AsciiDoc quality control
* Thanks to the AsciiDoc community for their excellent documentation and tools

Expand All @@ -179,12 +194,14 @@ This project is licensed under the MIT License - see the LICENSE file for detail
1. Phase 1 (Current)
* ✅ Basic heading rules
* ✅ Block structure rules
* ✅ Whitespace rules
* ✅ Image validation
* ⏳ Configuration system

2. Phase 2
* 🔲 Table validation
* 🔲 Link checking
* 🔲 Image validation
* 🔲 Format rules

3. Phase 3
* 🔲 IDE integration
Expand All @@ -193,5 +210,6 @@ This project is licensed under the MIT License - see the LICENSE file for detail

== Contact

* Project Homepage: https://github.com/yourusername/asciidoc-linter
* Issue Tracker: https://github.com/yourusername/asciidoc-linter/issues
* Project Homepage: https://github.com/docToolchain/asciidoc-linter
* Issue Tracker: https://github.com/docToolchain/asciidoc-linter/issues
* docToolchain Homepage: https://doctoolchain.org
2 changes: 1 addition & 1 deletion README.adoc.meta
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main documentation file for the AsciiDoc Linter project
Updated README with current implementation status
181 changes: 0 additions & 181 deletions asciidoc_linter/heading_rules.py

This file was deleted.

2 changes: 1 addition & 1 deletion asciidoc_linter/heading_rules.py.meta
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Updated implementation with fixed format checking
Implementation of heading rules with corrected imports
8 changes: 6 additions & 2 deletions asciidoc_linter/rules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# __init__.py - Rules package initialization

from .base_rules import Rule, Finding, Severity, Position
from .base import Rule, Finding, Severity, Position
from .heading_rules import HeadingHierarchyRule, HeadingFormatRule
from .block_rules import UnterminatedBlockRule, BlockSpacingRule
from .whitespace_rules import WhitespaceRule
from .image_rules import ImageAttributesRule

__all__ = [
'Rule',
Expand All @@ -12,5 +14,7 @@
'HeadingHierarchyRule',
'HeadingFormatRule',
'UnterminatedBlockRule',
'BlockSpacingRule'
'BlockSpacingRule',
'WhitespaceRule',
'ImageAttributesRule'
]
2 changes: 1 addition & 1 deletion asciidoc_linter/rules/__init__.py.meta
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Updated rules package initialization to include block rules
Rules package initialization with Position class
20 changes: 18 additions & 2 deletions asciidoc_linter/rules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,32 @@ class Severity(Enum):
WARNING = "WARNING"
ERROR = "ERROR"

class Position:
"""Represents a position in a text file"""
def __init__(self, line: int, column: Optional[int] = None):
self.line = line
self.column = column

def __str__(self):
if self.column is not None:
return f"line {self.line}, column {self.column}"
return f"line {self.line}"

class Finding:
"""Represents a rule violation finding"""
def __init__(self, rule_id: str, line_number: int, message: str,
def __init__(self, rule_id: str, position: Position, message: str,
severity: Severity, context: Optional[str] = None):
self.rule_id = rule_id
self.line_number = line_number
self.position = position
self.message = message
self.severity = severity
self.context = context

@property
def line_number(self) -> int:
"""Backward compatibility for line number access"""
return self.position.line

class Rule:
"""Base class for all rules"""
id: str = ""
Expand Down
2 changes: 1 addition & 1 deletion asciidoc_linter/rules/base.py.meta
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Base functionality for rules
Base functionality for rules including Position class
Loading

0 comments on commit 4c845f9

Please sign in to comment.