From e6ebd9662a7b3284b3d2468ead491c1f0eac074f Mon Sep 17 00:00:00 2001 From: Tibor Zavartkay Date: Thu, 16 Apr 2026 15:22:51 +0200 Subject: [PATCH 1/3] Fix for CPP literal include --- docs.bzl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs.bzl b/docs.bzl index a09ab0b29..5ecc27ed6 100644 --- a/docs.bzl +++ b/docs.bzl @@ -46,14 +46,17 @@ load("@docs_as_code_hub_env//:requirements.bzl", "all_requirements") load("@rules_python//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs") def _rewrite_needs_json_to_docs_sources(labels): - """Replace '@repo//:needs_json' -> '@repo//:docs_sources' for every item.""" + """Replace '@repo//:needs_json' -> '@repo//:docs_sources' for every item. + Note: Else path has been commented out as this prevented inclusion of CPP files + for case when fragment of code shall be displayed as literal include. + """ out = [] for x in labels: s = str(x) if s.endswith("//:needs_json"): out.append(s.replace("//:needs_json", "//:docs_sources")) - else: - out.append(s) + #else: + #out.append(s) return out def _rewrite_needs_json_to_sourcelinks(labels): From f0e940c16cf369da103e8f2d66776dbd07a31c5d Mon Sep 17 00:00:00 2001 From: Tibor Zavartkay Date: Thu, 16 Apr 2026 15:54:19 +0200 Subject: [PATCH 2/3] Modify the right function --- docs.bzl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs.bzl b/docs.bzl index 5ecc27ed6..94ddf7cdc 100644 --- a/docs.bzl +++ b/docs.bzl @@ -46,28 +46,28 @@ load("@docs_as_code_hub_env//:requirements.bzl", "all_requirements") load("@rules_python//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs") def _rewrite_needs_json_to_docs_sources(labels): - """Replace '@repo//:needs_json' -> '@repo//:docs_sources' for every item. - Note: Else path has been commented out as this prevented inclusion of CPP files - for case when fragment of code shall be displayed as literal include. - """ + """Replace '@repo//:needs_json' -> '@repo//:docs_sources' for every item.""" out = [] for x in labels: s = str(x) if s.endswith("//:needs_json"): out.append(s.replace("//:needs_json", "//:docs_sources")) - #else: - #out.append(s) + else: + out.append(s) return out def _rewrite_needs_json_to_sourcelinks(labels): - """Replace '@repo//:needs_json' -> '@repo//:sourcelinks_json' for every item.""" + """Replace '@repo//:needs_json' -> '@repo//:sourcelinks_json' for every item. + Note: Else path has been commented out as this prevented inclusion of CPP files + for case when fragment of code shall be displayed as literal include. + """ out = [] for x in labels: s = str(x) if s.endswith("//:needs_json"): out.append(s.replace("//:needs_json", "//:sourcelinks_json")) - else: - out.append(s) + #else: + #out.append(s) return out def _merge_sourcelinks(name, sourcelinks, known_good = None): From bec77efbada163266a86d6921f7c117dbb19d599 Mon Sep 17 00:00:00 2001 From: Tibor Zavartkay Date: Fri, 17 Apr 2026 15:28:10 +0200 Subject: [PATCH 3/3] Fix review findings --- docs.bzl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs.bzl b/docs.bzl index 94ddf7cdc..699c2370f 100644 --- a/docs.bzl +++ b/docs.bzl @@ -57,17 +57,14 @@ def _rewrite_needs_json_to_docs_sources(labels): return out def _rewrite_needs_json_to_sourcelinks(labels): - """Replace '@repo//:needs_json' -> '@repo//:sourcelinks_json' for every item. - Note: Else path has been commented out as this prevented inclusion of CPP files - for case when fragment of code shall be displayed as literal include. - """ + """Replace '@repo//:needs_json' -> '@repo//:sourcelinks_json' for every item.""" out = [] for x in labels: s = str(x) if s.endswith("//:needs_json"): out.append(s.replace("//:needs_json", "//:sourcelinks_json")) - #else: - #out.append(s) + #Items which do not end up with '//:needs_json' shall not be appended to 'out'. + #They are treated separately and are not related to source code linking. return out def _merge_sourcelinks(name, sourcelinks, known_good = None):