Skip to content

Commit 791ec1e

Browse files
author
Arnaud Riess
committed
refactor: move logging of existing links into inject_links_into_needs function
1 parent a1d32e6 commit 791ec1e

1 file changed

Lines changed: 11 additions & 33 deletions

File tree

src/extensions/score_source_code_linker/__init__.py

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -316,38 +316,6 @@ def find_need(all_needs: NeedsMutable, id: str) -> NeedItem | None:
316316
return all_needs.get(id)
317317

318318

319-
def _log_needs_with_existing_links(needs: NeedsMutable) -> None:
320-
"""Log needs that already have source_code_link or testlink set."""
321-
if LOGGER.getEffectiveLevel() >= 10:
322-
for id, need in needs.items():
323-
if need.get("source_code_link"):
324-
LOGGER.debug(
325-
f"?? Need {id} already has source_code_link: "
326-
f"{need.get('source_code_link')}"
327-
)
328-
if need.get("testlink"):
329-
LOGGER.debug(
330-
f"?? Need {id} already has testlink: {need.get('testlink')}"
331-
)
332-
333-
334-
def _warn_missing_need(source_code_links: SourceCodeLinks) -> None:
335-
"""Log warnings when a need referenced by source/test links is not found."""
336-
# TODO: print github annotations as in https://github.com/eclipse-score/bazel_registry/blob/7423b9996a45dd0a9ec868e06a970330ee71cf4f/tools/verify_semver_compatibility_level.py#L126-L129
337-
for n in source_code_links.links.CodeLinks:
338-
LOGGER.warning(
339-
f"{n.file}:{n.line}: Could not find {source_code_links.need} "
340-
"in documentation [CODE LINK]",
341-
type="score_source_code_linker",
342-
)
343-
for n in source_code_links.links.TestLinks:
344-
LOGGER.warning(
345-
f"{n.file}:{n.line}: Could not find {source_code_links.need} "
346-
"in documentation [TEST LINK]",
347-
type="score_source_code_linker",
348-
)
349-
350-
351319
# re-qid: gd_req__req__attr_impl
352320
def inject_links_into_needs(app: Sphinx, env: BuildEnvironment) -> None:
353321
"""
@@ -369,7 +337,17 @@ def inject_links_into_needs(app: Sphinx, env: BuildEnvironment) -> None:
369337
) # TODO: why do we create a copy? Can we also needs_copy = needs[:]? copy(needs)?
370338

371339
# Enabled automatically for DEBUGGING
372-
_log_needs_with_existing_links(needs)
340+
if LOGGER.getEffectiveLevel() >= 10:
341+
for id, need in needs.items():
342+
if need.get("source_code_link"):
343+
LOGGER.debug(
344+
f"?? Need {id} already has source_code_link: "
345+
f"{need.get('source_code_link')}"
346+
)
347+
if need.get("testlink"):
348+
LOGGER.debug(
349+
f"?? Need {id} already has testlink: {need.get('testlink')}"
350+
)
373351

374352
scl_by_module = load_repo_source_links_json(
375353
get_cache_filename(app.outdir, "score_repo_grouped_scl_cache.json")

0 commit comments

Comments
 (0)