From the docs_validator root directory:
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -e ".[dev]"Scenario: developing docs_validator and debugging it against the system located in a sibling directory
- Make changes in
../docs_validator/src/docs_validator/. - Re-run the validation command. Recompilation or
pip installis not required.
Check without creating a commit:
bash .githooks/pre-commitCommit, skip check:
git commit --no-verify# With coverage
pytest --cov=src/docs_validator --cov-report=term
# Verbose output
pytest tests/unit/ -vv --tb=shortThe repository uses a native hook to check before committing. The hook blocks the commit if tests fail or coverage is <70%.
chmod +x .githooks/pre-commit
git config core.hooksPath .githookssource .venv/bin/activate
pip install -e ".[dev]"cd ../project_to_validate/ && source .venv/bin/activate
pip install -e ../docs_validator --upgradeTo configure pytest templates in PyCharm:
- Additional arguments:
-vv --tb=short --color=yes --cov=src/docs_validator --cov-report=term -p no:warnings - Working directory:
$ProjectFileDir$ - Environment variables:
PYTEST_ADDOPTS="-vv --tb=short --color=yes"
To verify the docs_validator's functionality on a real documentation project (e.g., notes_and_thoughts):
- Setup: Ensure
docs_validatoris installed in editable mode with[dev]dependencies in an adjacent directory. - Clone Test Repository:
git clone https://gitlab.com/Nokhrin/notes_and_thoughts.git(or any target project). - Run Full Validation:
docs_validator scan ../notes_and_thoughts --validate --report html --output /tmp/report.html --log-level info
- Analyze Results: Open
/tmp/report.htmlin a browser. Verify sections: Issues Summary, Broken Links, Orphan Files, and Missing Anchors. - Strict Mode (CI Simulation):
docs_validator scan ../notes_and_thoughts --validate --fail-on-error echo "Exit code: $?" # Should be 1 if ERRORs exist, 0 otherwise.
- Test Configuration Auto-loading: Create a
.docs_validator.tomlin the root ofnotes_and_thoughtsand rundocs_validator scanwithout flags to verify settings are applied.
- The
docs_validatorproject and the tested project (e.g.,project_to_validate) are cloned into adjacent directories. - The tested project has a virtual environment with
docs_validatorinstalled in editable mode. - Interpreter (
.venv) of project under test is added to PyCharm
-
Create a new configuration:
Run->Edit Configurations...->+->Python -
Fill in the parameters:
Parameter Value Python interpreter Interpreter from the tested project's .venvScript path $ProjectFileDir$/src/docs_validator/cli.pyModule name (leave empty) Parameters scan ../project_to_validate --validate --log-level debugWorking directory $ProjectFileDir$/../project_to_validateEnvironment variables PYTHONDONTWRITEBYTECODE=1;PYTHONUNBUFFERED=1 -
Set breakpoints.
-
Run
Debug.
-
Create a configuration:
Run->Edit Configurations...->+->pytest -
Parameters:
Parameter Value Name pytest unit testsTarget path/to/docs_validator/tests/unit/Additional arguments -vv --tb=short --color=yes -s --log-cli-level=DEBUGWorking directory $ProjectFileDir$Environment variables (leave empty)
| Scenario | Cause | Solution |
|---|---|---|
docs_validator: command not found |
venv is not activated or PATH is not updated |
Run source .venv/bin/activate or use python -m docs_validator.cli scan . |
Settings are read from docs_validator instead of project_to_validate |
In cli.py, the config is searched in Path.cwd() / ".docs_validator.toml" |
Run the command from project_to_validate or explicitly specify --config ./docs_validator.toml |
| Absolute paths are displayed in reports | FilesExplorer builds paths relative to root_path |
Pass a relative path (. or ./docs) to scan, not an absolute one |
| Dependencies are not resolved | pyproject.toml in docs_validator requires networkx |
The [dev] flag in pip install automatically installs dependencies from dependencies and optional-dependencies |