diff --git a/.github/actions/link-check/link_parser.py b/.github/actions/link-check/link_parser.py index 2d7222ae..66a22f1b 100644 --- a/.github/actions/link-check/link_parser.py +++ b/.github/actions/link-check/link_parser.py @@ -61,7 +61,7 @@ def generate_markdown_table(broken_links: list[BrokenLink]) -> str: def generate_issue_body(broken_links: list[BrokenLink]) -> str: markdown_table = generate_markdown_table(broken_links) return f""" -# Broken Links Report. +# Broken Links Report. **Last updated: {datetime.now().strftime('%d-%m-%Y %H:%M')}** The following broken links were detected in the documentation: @@ -71,9 +71,9 @@ def generate_issue_body(broken_links: list[BrokenLink]) -> str: > To test locally if all link issues are resolved use `bazel run //:docs_link_check` ---- +--- This issue will be auto updated regularly if link issues are found. -You may close it if you wish, though a new one will be created if link issues are still present. +You may close it if you wish, though a new one will be created if link issues are still present. """ diff --git a/.github/workflows/consumer_test.yml b/.github/workflows/consumer_test.yml index 15b15478..913aed95 100644 --- a/.github/workflows/consumer_test.yml +++ b/.github/workflows/consumer_test.yml @@ -39,7 +39,7 @@ jobs: run: | mkdir -p reports - # The pipefail ensures that non 0 exit codes inside the pytest execution get carried into the pipe + # The pipefail ensures that non 0 exit codes inside the pytest execution get carried into the pipe # & make the tests red in the end. Without this we only would check the exit code of the 'tee' command. - name: Run Consumer tests diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8417b6c1..eea69f21 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,5 +34,8 @@ jobs: repository-cache: true bazelisk-cache: true - - name: Run Linter Script - run: bash scripts/run-linters.sh + - name: Install pre-commit + run: pip install pre-commit + + - name: Run pre-commit checks + run: pre-commit run -a diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..1012be46 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-yaml + - id: check-toml + - id: check-json + exclude: ^\.vscode/ # those are actually jsonc files + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-merge-conflict + - id: check-case-conflict + - id: mixed-line-ending + - id: detect-private-key + - id: check-added-large-files + args: ["--maxkb=150"] + + # use LOCAL hooks for python tooling so versions come from the virtualenv + - repo: local + hooks: + - id: Linter Scripts + name: Run linter script + entry: ./scripts/run-linters.sh + language: unsupported_script + pass_filenames: false diff --git a/README.md b/README.md index 0f2d5762..b72cea5c 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,21 @@ If your IDE does not automatically ask you to activate the newly created environ - In VSCode via `ctrl+p` => `Select Python Interpreter` then select `.venv_docs/bin/python` - In the terminal via `. .venv_docs/bin/activate` + +### Enabeling pre-commit + +Pre-commit is supported inside docs-as-code to help with code quality and make developers workflow easier. + +Install the hook: +```bash +pre-commit install + +# Or install it to run on pre-push via: +pre-commit install --hook-type pre-push +``` + +Execute the pre-commit manually via `pre-commit` + ### Format your documentation with: ```bash diff --git a/docs/internals/extensions/source_code_linker.md b/docs/internals/extensions/source_code_linker.md index 2f53c840..e97c4b6f 100644 --- a/docs/internals/extensions/source_code_linker.md +++ b/docs/internals/extensions/source_code_linker.md @@ -1,7 +1,7 @@ (source-code-linker)= # Score Source Code Linker -A Sphinx extension for enabling **source code and test traceability** for requirements. +A Sphinx extension for enabling **source code and test traceability** for requirements. This extension integrates with **Bazel** and **sphinx-needs** to automatically generate traceability links between implementation, tests, and documentation. --- @@ -272,9 +272,9 @@ flowchart TD L4[DTFL = DataForTestLink] L3[TestCaseNeed Operations] L5[DOTC = DataOfTestCase] - L1 ~~~ L2 - L2 ~~~ L4 - L4 ~~~ L3 + L1 ~~~ L2 + L2 ~~~ L4 + L4 ~~~ L3 L3 ~~~ L5 end diff --git a/docs/internals/requirements/requirements.rst b/docs/internals/requirements/requirements.rst index 55bfb953..819049f5 100644 --- a/docs/internals/requirements/requirements.rst +++ b/docs/internals/requirements/requirements.rst @@ -997,16 +997,16 @@ Testing Docs-As-Code shall enforce that needs of type :need:`tool_req__docs_saf_types` have a `violates` links to at least one dynamic / static diagram according to the table. - + .. table:: :widths: auto - + ============= =================== - Link Source Allowed Link Target + Link Source Allowed Link Target ============= =================== - feat_saf_dfa feat_arc_sta - comp_saf_dfa comp_arc_sta - feat_saf_fmea feat_arc_dyn + feat_saf_dfa feat_arc_sta + comp_saf_dfa comp_arc_sta + feat_saf_fmea feat_arc_dyn comp_saf_fmea comp_arc_dyn ============= =================== diff --git a/scripts/run-linters.sh b/scripts/run-linters.sh index 83b0436d..b5bead94 100755 --- a/scripts/run-linters.sh +++ b/scripts/run-linters.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # ******************************************************************************* # Copyright (c) 2025 Contributors to the Eclipse Foundation # @@ -10,7 +11,6 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -#!/usr/bin/env bash set -euo pipefail bazel run //:ide_support diff --git a/src/extensions/score_layout/assets/css/score_needs.css b/src/extensions/score_layout/assets/css/score_needs.css index 19047ba4..0a800e81 100644 --- a/src/extensions/score_layout/assets/css/score_needs.css +++ b/src/extensions/score_layout/assets/css/score_needs.css @@ -84,4 +84,3 @@ html[data-theme="light"] #logo_center_drk { display:none; } - diff --git a/src/extensions/score_metamodel/tests/rst/options/test_options_extra_option.rst b/src/extensions/score_metamodel/tests/rst/options/test_options_extra_option.rst index fd7de88e..a363f8ac 100644 --- a/src/extensions/score_metamodel/tests/rst/options/test_options_extra_option.rst +++ b/src/extensions/score_metamodel/tests/rst/options/test_options_extra_option.rst @@ -25,5 +25,3 @@ .. std_wp:: This is a test :id: std_wp__test__abce - - diff --git a/src/extensions/score_source_code_linker/tests/expected_codelink.json b/src/extensions/score_source_code_linker/tests/expected_codelink.json index 457d6a61..447ef8a6 100644 --- a/src/extensions/score_source_code_linker/tests/expected_codelink.json +++ b/src/extensions/score_source_code_linker/tests/expected_codelink.json @@ -7,7 +7,7 @@ "full_line": "#-----req-Id: TREQ_ID_1" }, { - "file": "src/implementation2.py", + "file": "src/implementation2.py", "line": 5, "tag":"#-----req-Id:", "need": "TREQ_ID_1", @@ -17,7 +17,7 @@ "file": "src/implementation1.py", "line": 9, "tag":"#-----req-Id:", - "need": "TREQ_ID_2", + "need": "TREQ_ID_2", "full_line":"#-----req-Id: TREQ_ID_2" }, { diff --git a/src/extensions/score_source_code_linker/tests/expected_grouped.json b/src/extensions/score_source_code_linker/tests/expected_grouped.json index b5abf26c..25623266 100644 --- a/src/extensions/score_source_code_linker/tests/expected_grouped.json +++ b/src/extensions/score_source_code_linker/tests/expected_grouped.json @@ -11,7 +11,7 @@ "full_line": "#-----req-Id: TREQ_ID_1" }, { - "file": "src/implementation2.py", + "file": "src/implementation2.py", "line": 5, "tag":"#-----req-Id:", "need": "TREQ_ID_1", @@ -40,7 +40,7 @@ "file": "src/implementation1.py", "line": 9, "tag":"#-----req-Id:", - "need": "TREQ_ID_2", + "need": "TREQ_ID_2", "full_line":"#-----req-Id: TREQ_ID_2" } ], diff --git a/src/requirements.in b/src/requirements.in index 442e74c7..04192109 100644 --- a/src/requirements.in +++ b/src/requirements.in @@ -30,4 +30,3 @@ rich needs-config-writer == 0.2.4 # use this for a specific commit for fast development iterations # needs-config-writer @ https://github.com/useblocks/needs-config-writer/archive/032a5f8.zip -