Skip to content

Commit 31defe7

Browse files
chore: enable pre-commit configuration (#417)
1 parent b5b5b89 commit 31defe7

13 files changed

Lines changed: 64 additions & 25 deletions

File tree

.github/actions/link-check/link_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def generate_markdown_table(broken_links: list[BrokenLink]) -> str:
6161
def generate_issue_body(broken_links: list[BrokenLink]) -> str:
6262
markdown_table = generate_markdown_table(broken_links)
6363
return f"""
64-
# Broken Links Report.
64+
# Broken Links Report.
6565
**Last updated: {datetime.now().strftime('%d-%m-%Y %H:%M')}**
6666
6767
The following broken links were detected in the documentation:
@@ -71,9 +71,9 @@ def generate_issue_body(broken_links: list[BrokenLink]) -> str:
7171
7272
> To test locally if all link issues are resolved use `bazel run //:docs_link_check`
7373
74-
---
74+
---
7575
This issue will be auto updated regularly if link issues are found.
76-
You may close it if you wish, though a new one will be created if link issues are still present.
76+
You may close it if you wish, though a new one will be created if link issues are still present.
7777
7878
"""
7979

.github/workflows/consumer_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: |
4040
mkdir -p reports
4141
42-
# The pipefail ensures that non 0 exit codes inside the pytest execution get carried into the pipe
42+
# The pipefail ensures that non 0 exit codes inside the pytest execution get carried into the pipe
4343
# & make the tests red in the end. Without this we only would check the exit code of the 'tee' command.
4444
- name: Run Consumer tests
4545

.github/workflows/lint.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ jobs:
3434
repository-cache: true
3535
bazelisk-cache: true
3636

37-
- name: Run Linter Script
38-
run: bash scripts/run-linters.sh
37+
- name: Install pre-commit
38+
run: pip install pre-commit
39+
40+
- name: Run pre-commit checks
41+
run: pre-commit run -a

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-yaml
6+
- id: check-toml
7+
- id: check-json
8+
exclude: ^\.vscode/ # those are actually jsonc files
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
- id: check-merge-conflict
12+
- id: check-case-conflict
13+
- id: mixed-line-ending
14+
- id: detect-private-key
15+
- id: check-added-large-files
16+
args: ["--maxkb=150"]
17+
18+
# use LOCAL hooks for python tooling so versions come from the virtualenv
19+
- repo: local
20+
hooks:
21+
- id: Linter Scripts
22+
name: Run linter script
23+
entry: ./scripts/run-linters.sh
24+
language: unsupported_script
25+
pass_filenames: false

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ If your IDE does not automatically ask you to activate the newly created environ
1818
- In VSCode via `ctrl+p` => `Select Python Interpreter` then select `.venv_docs/bin/python`
1919
- In the terminal via `. .venv_docs/bin/activate`
2020

21+
22+
### Enabeling pre-commit
23+
24+
Pre-commit is supported inside docs-as-code to help with code quality and make developers workflow easier.
25+
26+
Install the hook:
27+
```bash
28+
pre-commit install
29+
30+
# Or install it to run on pre-push via:
31+
pre-commit install --hook-type pre-push
32+
```
33+
34+
Execute the pre-commit manually via `pre-commit`
35+
2136
### Format your documentation with:
2237

2338
```bash

docs/internals/extensions/source_code_linker.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(source-code-linker)=
22
# Score Source Code Linker
33

4-
A Sphinx extension for enabling **source code and test traceability** for requirements.
4+
A Sphinx extension for enabling **source code and test traceability** for requirements.
55
This extension integrates with **Bazel** and **sphinx-needs** to automatically generate traceability links between implementation, tests, and documentation.
66

77
---
@@ -272,9 +272,9 @@ flowchart TD
272272
L4[DTFL = DataForTestLink]
273273
L3[TestCaseNeed Operations]
274274
L5[DOTC = DataOfTestCase]
275-
L1 ~~~ L2
276-
L2 ~~~ L4
277-
L4 ~~~ L3
275+
L1 ~~~ L2
276+
L2 ~~~ L4
277+
L4 ~~~ L3
278278
L3 ~~~ L5
279279
end
280280

docs/internals/requirements/requirements.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -997,16 +997,16 @@ Testing
997997
Docs-As-Code shall enforce that needs of type :need:`tool_req__docs_saf_types` have a
998998
`violates` links to at least one dynamic / static diagram according to the table.
999999

1000-
1000+
10011001
.. table::
10021002
:widths: auto
1003-
1003+
10041004
============= ===================
1005-
Link Source Allowed Link Target
1005+
Link Source Allowed Link Target
10061006
============= ===================
1007-
feat_saf_dfa feat_arc_sta
1008-
comp_saf_dfa comp_arc_sta
1009-
feat_saf_fmea feat_arc_dyn
1007+
feat_saf_dfa feat_arc_sta
1008+
comp_saf_dfa comp_arc_sta
1009+
feat_saf_fmea feat_arc_dyn
10101010
comp_saf_fmea comp_arc_dyn
10111011
============= ===================
10121012

scripts/run-linters.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
# *******************************************************************************
23
# Copyright (c) 2025 Contributors to the Eclipse Foundation
34
#
@@ -10,7 +11,6 @@
1011
#
1112
# SPDX-License-Identifier: Apache-2.0
1213
# *******************************************************************************
13-
#!/usr/bin/env bash
1414
set -euo pipefail
1515

1616
bazel run //:ide_support

src/extensions/score_layout/assets/css/score_needs.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,3 @@ html[data-theme="light"] #logo_center_drk {
8484
display:none;
8585

8686
}
87-

src/extensions/score_metamodel/tests/rst/options/test_options_extra_option.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@
2525

2626
.. std_wp:: This is a test
2727
:id: std_wp__test__abce
28-
29-

0 commit comments

Comments
 (0)