Skip to content

Conversation

@MaximilianSoerenPollak
Copy link
Contributor

@MaximilianSoerenPollak MaximilianSoerenPollak commented Jul 7, 2025

This is a fix for the source code linker.

It addresses several things especially the #118 .

The README has not yet been fully changed, though this will be done in a future PR.

This has been developed together with @AlexanderLanin

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //src:license-check

Status: ✅ Passed

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 287ffd20-cab9-4e2d-8770-7e3ba905393a
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: src
Loading: 0 packages loaded
    currently loading: src
Analyzing: target //src:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //src:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //src:license-check (96 packages loaded, 10 targets configured)

Analyzing: target //src:license-check (139 packages loaded, 509 targets configured)

Analyzing: target //src:license-check (150 packages loaded, 1789 targets configured)

Analyzing: target //src:license-check (153 packages loaded, 2652 targets configured)

Analyzing: target //src:license-check (158 packages loaded, 2687 targets configured)

Analyzing: target //src:license-check (162 packages loaded, 4820 targets configured)

INFO: Analyzed target //src:license-check (163 packages loaded, 4946 targets configured).
INFO: Found 1 target...
Target //src:license.check.license_check up-to-date:
  bazel-bin/src/license.check.license_check
  bazel-bin/src/license.check.license_check.jar
INFO: Elapsed time: 15.234s, Critical Path: 0.37s
INFO: 13 processes: 4 disk cache hit, 9 internal.
INFO: Build completed successfully, 13 total actions
INFO: Running command line: bazel-bin/src/license.check.license_check src/formatted.txt -review -project automotive.score -repo https://github.com/eclipse-score/docs-as-code -token otyhZ4eaRYK1tKLNNF-Y
[main] INFO Querying Eclipse Foundation for license data for 83 items.
[main] INFO Found 58 items.
[main] INFO Querying ClearlyDefined for license data for 25 items.
[main] INFO Found 25 items.
[main] INFO Vetted license information was found for all content. No further investigation is required.

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

The created documentation from the pull request is available at: docu-html

@dcalavrezo-qorix dcalavrezo-qorix requested a review from Copilot July 7, 2025 09:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the source code linker integration (especially issue #118) by standardizing workspace path handling, removing the legacy parser, and rewriting tests to use temporary Git repositories and JSON cache files.

  • Prepend BUILD_WORKSPACE_DIRECTORY to all source, build, and conf paths in incremental.py
  • Remove old parse_source_files.py and Bazel aspect; introduce generate_source_code_links_json.py
  • Refactor tests to initialize real Git repos, generate and compare JSON cache files, and inject links via the new Sphinx extension

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/incremental.py Prefixes all env-derived paths with workspace, fixes live_preview cache removal
src/extensions/score_source_code_linker/generate_source_code_links_json.py New module to scan for need tags and emit JSON cache
src/extensions/score_source_code_linker/init.py Switch to JSON-backed linking in Sphinx setup, remove old inline parser
src/extensions/score_source_code_linker/needlinks.py Minor tweaks, but functionally unchanged
src/extensions/score_source_code_linker/tests/test_source_link.py Tests rewritten to spin up Git repos and validate JSON cache
src/extensions/score_source_code_linker/tests/test_requirement_links.py Expanded fixtures for multiple Git scenarios and JSON encoder/decoder
docs/product/extensions/source_code_linker.md Updated example snippet
src/extensions/score_source_code_linker/BUILD Test target now includes JSON data files
Comments suppressed due to low confidence (1)

docs/product/extensions/source_code_linker.md:19

  • [nitpick] The example snippet is confusing due to the embedded HTML comment. Simplify it to show the actual tag format (e.g., # req-traceability:) without extra markup.
   - Scans input files for template tags (e.g., "#<!-- comment prevents parsing this occurance --> req-traceability:")

build_dir = Path(get_env("BUILD_DIRECTORY"))
(workspace / build_dir / "score_source_code_linker_cache.json").unlink(
missing_ok=False
)
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workspace is a string, so workspace / build_dir will raise a TypeError. Convert workspace to a Path before using / or use Path(workspace) / build_dir.

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +83
# if workspace:
# os.chdir(workspace)
if workspace:
os.chdir(workspace)
workspace += "/"
else:
workspace = ""

base_arguments = [
get_env("SOURCE_DIRECTORY"),
get_env("BUILD_DIRECTORY"),
workspace + get_env("SOURCE_DIRECTORY"),
workspace + get_env("BUILD_DIRECTORY"),
"-W", # treat warning as errors
"--keep-going", # do not abort after one error
"-T", # show details in case of errors in extensions
"--jobs",
"auto",
"--conf-dir",
get_env("CONF_DIRECTORY"),
workspace + get_env("CONF_DIRECTORY"),
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Manually appending a slash is brittle; consider keeping workspace as a Path and using workspace / get_env(...) for joins instead of string concatenation.

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +61
print(f"DEBUG: Workspace root is {find_ws_root()}")
print(f"DEBUG: Current working directory is {Path('.')} = {Path('.').resolve()}")
print(f"DEBUG: Git root is {find_git_root()}")
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use LOGGER.debug(...) instead of print(...) for debug output to maintain consistent logging and avoid polluting stdout.

Suggested change
print(f"DEBUG: Workspace root is {find_ws_root()}")
print(f"DEBUG: Current working directory is {Path('.')} = {Path('.').resolve()}")
print(f"DEBUG: Git root is {find_git_root()}")
LOGGER.debug(f"Workspace root is {find_ws_root()}")
LOGGER.debug(f"Current working directory is {Path('.')} = {Path('.').resolve()}")
LOGGER.debug(f"Git root is {find_git_root()}")

Copilot uses AI. Check for mistakes.
env: Buildenvironment, this is filled automatically
app: Sphinx app application, this is filled automatically
"""
print("inject_links_into_needs!!!!")
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove or replace this print statement with a debug-level log (LOGGER.debug) to avoid unexpected console output in production.

Suggested change
print("inject_links_into_needs!!!!")
LOGGER.debug("inject_links_into_needs!!!!")

Copilot uses AI. Check for mistakes.
Comment on lines +248 to +260
return [
{
"TREQ_ID_200": [
NeedLink(
file=Path(f"src/bad_implementation.py"),
line=2,
tag="#" + " req-Id:",
need="TREQ_ID_200",
full_line="#" + " req-Id: TREQ_ID_200",
)
]
}
]
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example_source_link_text_non_existent fixture returns a list, but the test signature expects a dict[str, list[str]]. Update the fixture or the test to match the expected type.

Copilot uses AI. Check for mistakes.
@MaximilianSoerenPollak MaximilianSoerenPollak marked this pull request as ready for review July 7, 2025 09:22
AlexanderLanin and others added 15 commits July 7, 2025 11:22
This is more complicated than anticipated
Git root is still an issue.
It doesn't behave as needed (for a nice unit test)
Tests were generated boilerplate.
Already altered / improved some, but not yet fully looked through.

Just wanted a starting point
Fixed tests working.
All test pass now
@MaximilianSoerenPollak
Copy link
Contributor Author

I just rebased it to eliminate the Merge issues.

@MaximilianSoerenPollak MaximilianSoerenPollak linked an issue Jul 7, 2025 that may be closed by this pull request
@MaximilianSoerenPollak MaximilianSoerenPollak merged commit 6a8b18f into main Jul 7, 2025
7 checks passed
@MaximilianSoerenPollak MaximilianSoerenPollak deleted the wip_simple_scp branch July 7, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

v0.4 does not work on score

4 participants