From 658f873b10de3390e885f6883965f89787dc1bbe Mon Sep 17 00:00:00 2001 From: Isaac Emmanuel <35623334+1cbyc@users.noreply.github.com> Date: Thu, 15 Oct 2026 07:20:31 +0000 Subject: [PATCH 1/2] chore: use devcontainer buildifier Signed-off-by: Isaac Emmanuel <35623334+1cbyc@users.noreply.github.com> --- .pre-commit-config.yaml | 7 +- BUILD | 11 +- MODULE.bazel | 2 - MODULE.bazel.lock | 143 +++++++++++++++++- bzl/basics.bzl | 14 +- bzl/bundle_rules.bzl | 50 +++--- bzl/code_file_lists.bzl | 1 + bzl/mount_rules.bzl | 1 + bzl/needs_rules.bzl | 2 + bzl/tests/basics_test.bzl | 1 + docs.bzl | 65 ++++---- scripts_bazel/BUILD | 2 +- scripts_bazel/tests/BUILD | 8 +- src/BUILD | 8 +- src/docs_cli/BUILD | 20 ++- src/extensions/score_metamodel/BUILD | 2 +- src/extensions/score_metamodel/docs/BUILD | 4 +- src/extensions/score_metrics/BUILD | 2 +- src/extensions/score_mounts/BUILD | 2 +- src/extensions/score_source_code_linker/BUILD | 6 +- src/extensions/score_sphinx_bundle/BUILD | 10 +- src/extensions/score_sync_toml/BUILD | 4 +- src/helper_lib/BUILD | 2 +- src/tests/docs_bzl/cross_module_fixture/BUILD | 2 +- .../cross_module_fixture/MODULE.bazel | 5 +- src/tests/docs_bzl/scenarios/basic_docs/BUILD | 4 +- .../docs_bzl/scenarios/coverage_summary/BUILD | 62 ++++++-- .../scenarios/data_files_runfiles/BUILD | 30 ++-- .../scenarios/deprecated_needs_data/BUILD | 6 +- .../docs_bzl/scenarios/external_bundle/BUILD | 4 +- .../scenarios/external_needs_inputs/BUILD | 8 +- .../scenarios/invalid_bundle_placements/BUILD | 56 +++++-- .../docs_bzl/scenarios/nested_bundles/BUILD | 24 +-- .../reference_integration/legacy_module/BUILD | 16 +- .../docs/components/component/BUILD | 2 +- .../reference_integration/modern_module/BUILD | 29 ++-- .../docs/components/component/BUILD | 2 +- .../docs/components/unlinked_component/BUILD | 6 +- .../docs_bzl/scenarios/root_docs_config/BUILD | 12 +- .../subdirectory_bundle/consumer/BUILD | 8 +- .../subdirectory_bundle/producer/BUILD | 8 +- tools/tests/BUILD | 4 +- 42 files changed, 456 insertions(+), 199 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36b4dff7b..280549d76 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,11 +33,10 @@ repos: - repo: local hooks: - - id: bazel-mod-tidy - name: format Bazel module files - entry: bazel mod tidy + - id: buildifier + name: format Bazel files + entry: .devcontainer/run-tool buildifier language: system - pass_filenames: false files: '(^|/)(MODULE\.bazel|.*\.bzl|BUILD(\.bazel)?)$' - id: bzlmod-lockfile diff --git a/BUILD b/BUILD index 0e1181d26..7a1434e22 100644 --- a/BUILD +++ b/BUILD @@ -14,16 +14,12 @@ load("//:docs.bzl", "docs") package(default_visibility = ["//visibility:public"]) + exports_files([ "pyproject.toml", ]) docs( - project = "S-CORE Docs-as-Code", - project_url = "https://eclipse-score.github.io/docs-as-code", - external_needs = [ - "@score_process_description//:needs_json_file", - ], bundles = [ { "bundle": "//src/extensions/docs:extensions", @@ -52,6 +48,11 @@ docs( "//tools:module_verification_reports", "//src:all_sources", ], + external_needs = [ + "@score_process_description//:needs_json_file", + ], + project = "S-CORE Docs-as-Code", + project_url = "https://eclipse-score.github.io/docs-as-code", source_dir = "docs", ) diff --git a/MODULE.bazel b/MODULE.bazel index 9e3b8345e..1c370aead 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -70,8 +70,6 @@ use_repo(pip, "docs_as_code_hub_env") # Additional Python rules provided by aspect, e.g. an improved version of bazel_dep(name = "aspect_rules_py", version = "1.4.0") -bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = True) - # PlantUML for docs bazel_dep(name = "rules_java", version = "8.15.1") bazel_dep(name = "score_tools", version = "0.0.4") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 7965dbf24..43c1c12cb 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -44,8 +44,7 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67", "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb", "https://bcr.bazel.build/modules/buildifier_prebuilt/7.3.1/MODULE.bazel": "537faf0ad9f5892910074b8e43b4c91c96f1d5d86b6ed04bdbe40cf68aa48b68", - "https://bcr.bazel.build/modules/buildifier_prebuilt/8.2.0.2/MODULE.bazel": "a9b689711d5b69f9db741649b218c119b9fdf82924ba390415037e09798edd03", - "https://bcr.bazel.build/modules/buildifier_prebuilt/8.2.0.2/source.json": "51eb0a4b38aaaeab7fa64361576d616c4d8bfd0f17a0a10184aeab7084d79f8e", + "https://bcr.bazel.build/modules/buildifier_prebuilt/7.3.1/source.json": "55153a5e6ca9c8a7e266c4b46b951e8a010d25ec6062bc35d5d4f89925796bad", "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", @@ -199,7 +198,6 @@ "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/bazel_skylib/1.8.1/MODULE.bazel": "not found", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/bazel_skylib/1.8.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/buildifier_prebuilt/7.3.1/MODULE.bazel": "not found", - "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/buildifier_prebuilt/8.2.0.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/buildozer/7.1.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/google_benchmark/1.8.2/MODULE.bazel": "not found", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/googletest/1.11.0/MODULE.bazel": "not found", @@ -414,6 +412,145 @@ ] } }, + "@@buildifier_prebuilt+//:defs.bzl%buildifier_prebuilt_deps_extension": { + "general": { + "bzlTransitiveDigest": "UuPPKtgkayflJh3xnoDcElnjA0xyLYaim0cMSFV12v8=", + "usagesDigest": "eWMDBEn8E8CrwAPXrlrjIap2pseSMhxDyDdrntHBOOE=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "buildifier_darwin_amd64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-darwin-amd64" + ], + "downloaded_file_path": "buildifier", + "executable": true, + "sha256": "375f823103d01620aaec20a0c29c6cbca99f4fd0725ae30b93655c6704f44d71" + } + }, + "buildifier_darwin_arm64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-darwin-arm64" + ], + "downloaded_file_path": "buildifier", + "executable": true, + "sha256": "5a6afc6ac7a09f5455ba0b89bd99d5ae23b4174dc5dc9d6c0ed5ce8caac3f813" + } + }, + "buildifier_linux_amd64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-linux-amd64" + ], + "downloaded_file_path": "buildifier", + "executable": true, + "sha256": "5474cc5128a74e806783d54081f581662c4be8ae65022f557e9281ed5dc88009" + } + }, + "buildifier_linux_arm64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-linux-arm64" + ], + "downloaded_file_path": "buildifier", + "executable": true, + "sha256": "0bf86c4bfffaf4f08eed77bde5b2082e4ae5039a11e2e8b03984c173c34a561c" + } + }, + "buildifier_windows_amd64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-windows-amd64.exe" + ], + "downloaded_file_path": "buildifier.exe", + "executable": true, + "sha256": "370cd576075ad29930a82f5de132f1a1de4084c784a82514bd4da80c85acf4a8" + } + }, + "buildozer_darwin_amd64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-darwin-amd64" + ], + "downloaded_file_path": "buildozer", + "executable": true, + "sha256": "854c9583efc166602276802658cef3f224d60898cfaa60630b33d328db3b0de2" + } + }, + "buildozer_darwin_arm64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-darwin-arm64" + ], + "downloaded_file_path": "buildozer", + "executable": true, + "sha256": "31b1bfe20d7d5444be217af78f94c5c43799cdf847c6ce69794b7bf3319c5364" + } + }, + "buildozer_linux_amd64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-linux-amd64" + ], + "downloaded_file_path": "buildozer", + "executable": true, + "sha256": "3305e287b3fcc68b9a35fd8515ee617452cd4e018f9e6886b6c7cdbcba8710d4" + } + }, + "buildozer_linux_arm64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-linux-arm64" + ], + "downloaded_file_path": "buildozer", + "executable": true, + "sha256": "0b5a2a717ac4fc911e1fec8d92af71dbb4fe95b10e5213da0cc3d56cea64a328" + } + }, + "buildozer_windows_amd64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-windows-amd64.exe" + ], + "downloaded_file_path": "buildozer.exe", + "executable": true, + "sha256": "58d41ce53257c5594c9bc86d769f580909269f68de114297f46284fbb9023dcf" + } + }, + "buildifier_prebuilt_toolchains": { + "repoRuleId": "@@buildifier_prebuilt+//:defs.bzl%_buildifier_toolchain_setup", + "attributes": { + "assets_json": "[{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"darwin\",\"sha256\":\"375f823103d01620aaec20a0c29c6cbca99f4fd0725ae30b93655c6704f44d71\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildifier\",\"platform\":\"darwin\",\"sha256\":\"5a6afc6ac7a09f5455ba0b89bd99d5ae23b4174dc5dc9d6c0ed5ce8caac3f813\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"linux\",\"sha256\":\"5474cc5128a74e806783d54081f581662c4be8ae65022f557e9281ed5dc88009\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildifier\",\"platform\":\"linux\",\"sha256\":\"0bf86c4bfffaf4f08eed77bde5b2082e4ae5039a11e2e8b03984c173c34a561c\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"windows\",\"sha256\":\"370cd576075ad29930a82f5de132f1a1de4084c784a82514bd4da80c85acf4a8\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"darwin\",\"sha256\":\"854c9583efc166602276802658cef3f224d60898cfaa60630b33d328db3b0de2\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildozer\",\"platform\":\"darwin\",\"sha256\":\"31b1bfe20d7d5444be217af78f94c5c43799cdf847c6ce69794b7bf3319c5364\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"linux\",\"sha256\":\"3305e287b3fcc68b9a35fd8515ee617452cd4e018f9e6886b6c7cdbcba8710d4\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildozer\",\"platform\":\"linux\",\"sha256\":\"0b5a2a717ac4fc911e1fec8d92af71dbb4fe95b10e5213da0cc3d56cea64a328\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"windows\",\"sha256\":\"58d41ce53257c5594c9bc86d769f580909269f68de114297f46284fbb9023dcf\",\"version\":\"v7.3.1\"}]" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "buildifier_prebuilt+", + "bazel_skylib", + "bazel_skylib+" + ], + [ + "buildifier_prebuilt+", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, "@@pybind11_bazel+//:python_configure.bzl%extension": { "general": { "bzlTransitiveDigest": "D2/qWHU6yQFwRG7Bb+caqrYMha5avsASao2vERrxK24=", diff --git a/bzl/basics.bzl b/bzl/basics.bzl index c6ccf56d1..d70025766 100644 --- a/bzl/basics.bzl +++ b/bzl/basics.bzl @@ -44,8 +44,18 @@ def dirname(path): def glob_doc_sources(prefix): """Return glob patterns for documentation sources below ``prefix``.""" extensions = [ - "png", "svg", "md", "rst", "html", "css", - "puml", "need", "yaml", "json", "csv", "inc", + "png", + "svg", + "md", + "rst", + "html", + "css", + "puml", + "need", + "yaml", + "json", + "csv", + "inc", ] param = [join_path(prefix, "**/*." + ext) for ext in extensions] srcs = native.glob(param, allow_empty = True) diff --git a/bzl/bundle_rules.bzl b/bzl/bundle_rules.bzl index 4f652ad1b..2799db25d 100644 --- a/bzl/bundle_rules.bzl +++ b/bzl/bundle_rules.bzl @@ -28,8 +28,6 @@ # its entries are consumed by the mounts manifest action. Keeping both consumers # on this provider ensures that source ownership and runtime placement agree. - - load("@score_docs_as_code//:bzl/basics.bzl", "join_path") # Internal data passed between bundle targets and eventually consumed by an @@ -83,6 +81,7 @@ CodeTargetSourcesInfo = provider( def _source_files_from_attributes(ctx): """Return files explicitly declared through source or header attributes.""" + # DefaultInfo resolves filegroups and generator outputs at the attribute # boundary. We inspect the consuming library's declarations, so generator # inputs and the library's compiled outputs do not enter the file list. @@ -277,6 +276,7 @@ def _source_dir_runtime_path(ctx): def _source_target_path(source_file): """Return the path spelling used by the source-target staging action.""" + # Bazel marks workspace files with ``is_source``; generated outputs use # the execroot path while workspace files use their runfiles short path. return source_file.path if not source_file.is_source else source_file.short_path @@ -294,6 +294,7 @@ def _source_targets_runtime_path(files): first_path = _source_target_path(first_file) first_is_source = first_file.is_source separator = first_path.rfind("/") + # A root-package source has no parent component; ``.`` represents the # workspace/execroot root so it can still be used as the shared directory. runtime_path = first_path[:separator] if separator >= 0 else "." @@ -305,6 +306,7 @@ def _source_targets_runtime_path(files): fail(("explicit bundle sources cannot mix workspace and generated files; " + "found %r and %r") % (first_path, source_path)) source_separator = source_path.rfind("/") + # Use the same ``.`` spelling for another root-package source. source_root = source_path[:source_separator] if source_separator >= 0 else "." if source_root != runtime_path: @@ -317,6 +319,7 @@ def _source_targets_relative_paths(files, runtime_path): relative_paths = [] for source_file in files: source_path = _source_target_path(source_file) + # A root-package source has ``.`` as its shared parent, so its complete # path is already relative to the staging tree. if runtime_path == ".": @@ -342,15 +345,16 @@ def _pure_data_runtime_path(ctx): Give them a synthetic, label-derived identity so multiple distinct pure-data bundles can be composed into one documentation site. """ + # Encode the complete label identity so every target gets a stable, # distinct synthetic path. In particular, local and external labels remain # distinct when both are composed by one consuming project. label = str(ctx.label) encoded_label = ( label.replace("%", "%25") - .replace("@", "%40") - .replace("/", "%2F") - .replace(":", "%3A") + .replace("@", "%40") + .replace("/", "%2F") + .replace(":", "%3A") ) return "__data__/%s" % encoded_label @@ -464,6 +468,7 @@ def _docs_bundle_impl(ctx): own_bundle_label = str(ctx.label) own_bundle_name = ctx.label.name own_primary_need_id = ctx.attr.primary_need_id + # Keep implementation ownership with the declaring documentation entry. # The metamodel resolves its primary Need from that entry's own documents; # rebasing into a parent preserves the same bounded implementation file set. @@ -514,6 +519,7 @@ def _docs_bundle_impl(ctx): code_files = own_code_files, )) own_source_files.extend(ctx.files.source_dir_globbed) + # Local sources are read directly from the workspace by ``bazel run``. # Only sources from external repositories must be staged in runfiles. if external: @@ -558,6 +564,7 @@ def _docs_bundle_impl(ctx): code_files = own_code_files, )) own_source_files.extend(ctx.files.source_targets) + # Explicit artifacts outside the workspace source tree need to be # staged for ``bazel run`` just like external source bundles. if not ctx.files.source_targets[0].is_source or external: @@ -723,22 +730,22 @@ _docs_bundle = rule( ) def create_bundle( - name, - bundles, - source_dir_globbed = [], - source_targets = [], - sourcelinks_json = None, - source_dir = None, - entry_doc = "index", - primary_need_id = None, - data = [], - code_targets = [], - code_files = None, - root_docs_config = None, - is_root_bundle = False, - project_name = None, - visibility = None, - **kwargs): + name, + bundles, + source_dir_globbed = [], + source_targets = [], + sourcelinks_json = None, + source_dir = None, + entry_doc = "index", + primary_need_id = None, + data = [], + code_targets = [], + code_files = None, + root_docs_config = None, + is_root_bundle = False, + project_name = None, + visibility = None, + **kwargs): """Create a bundle from directory-discovered files and source targets. ``source_dir_globbed`` and ``source_targets`` are separate internal inputs @@ -749,6 +756,7 @@ def create_bundle( A root docs configuration, when present, remains authoritative. """ parsed_bundles = [_parse_bundle_declaration(declaration) for declaration in bundles] + # The public macros use ``None`` to represent an omitted optional ID, but # the underlying Bazel rule has a string attribute and the manifest schema # keeps this field string-valued. Normalize at that boundary so callers do diff --git a/bzl/code_file_lists.bzl b/bzl/code_file_lists.bzl index 5c0968b8d..f024175e4 100644 --- a/bzl/code_file_lists.bzl +++ b/bzl/code_file_lists.bzl @@ -26,6 +26,7 @@ def _file_identity(file): repository, _, path = path[3:].partition("/") else: repository = "_main" + # short_path already omits the configuration root for generated outputs. return struct(repository = repository, path = path) diff --git a/bzl/mount_rules.bzl b/bzl/mount_rules.bzl index 2b5d5a410..eee5fb037 100644 --- a/bzl/mount_rules.bzl +++ b/bzl/mount_rules.bzl @@ -63,6 +63,7 @@ def _composition_manifest_impl(ctx): ], }, } + # Explicit source targets are mounted as a file allowlist. Directory # bundles omit this key and retain the existing recursive behavior. if entry.files: diff --git a/bzl/needs_rules.bzl b/bzl/needs_rules.bzl index d0ec85d05..2913411ae 100644 --- a/bzl/needs_rules.bzl +++ b/bzl/needs_rules.bzl @@ -30,6 +30,7 @@ def _sphinx_docs_impl(ctx): output = ctx.actions.declare_directory(ctx.label.name + "/_build/needs") bundle = ctx.attr.bundle[DocsBundleInfo] + # The bundle owns both the direct inputs and their execution-root-relative # source root. Nested sources are provided separately for score_mounts, so # local exports retain their bundle ownership. @@ -54,6 +55,7 @@ def _sphinx_docs_impl(ctx): project_url = bundle_config.project_url, required_in_id = bundle_config.required_in_id, ) + # Configuration-free actions need a concrete metamodel input. Use an # explicitly supplied label first, then the bundle's inherited default. metamodel_file = ctx.file.score_metamodel_yaml or bundle_config.metamodel diff --git a/bzl/tests/basics_test.bzl b/bzl/tests/basics_test.bzl index b11d34bfd..eeb5f07cf 100644 --- a/bzl/tests/basics_test.bzl +++ b/bzl/tests/basics_test.bzl @@ -19,6 +19,7 @@ load("//:bzl/basics.bzl", "join_path") def _join_path_test_impl(ctx): """Check path joining and normalization at the Starlark level.""" env = unittest.begin(ctx) + # Each tuple contains ``prefix``, ``rest``, and the expected result. cases = [ ("docs", "index", "docs/index"), diff --git a/docs.bzl b/docs.bzl index 47bd8faf1..cb11f41f5 100644 --- a/docs.bzl +++ b/docs.bzl @@ -75,6 +75,7 @@ load( "@score_docs_as_code//:bzl/mount_rules.bzl", "create_composition_manifest", ) + # Keep the low-level action behind this name so this macro owns the shared # Sphinx policy while ``needs_rules.bzl`` owns Bazel's input/output plumbing. load("@score_docs_as_code//:bzl/needs_rules.bzl", "sphinx_docs") @@ -94,15 +95,16 @@ def _needs_sphinx_extra_opts( These values cross the Bazel action boundary as command-line options. The shared warning and traceback flags are supplied by the launcher instead. """ + # The launcher supplies diagnostics shared by every builder. Keep only # target-specific defines here so the action does not receive duplicate # ``-W``, ``--keep-going``, and ``-T`` options after JSON transport. return [ option for name, value in [ - ("master_doc", master_doc), - ("score_bundle_needs_export", score_bundle_needs_export), - ("score_source_code_linker_plain_links", score_source_code_linker_plain_links), + ("master_doc", master_doc), + ("score_bundle_needs_export", score_bundle_needs_export), + ("score_source_code_linker_plain_links", score_source_code_linker_plain_links), ] for option in _sphinx_define(name, value) ] @@ -143,6 +145,7 @@ def _needs_sphinx_docs( String settings travel as Sphinx ``--define`` options. Bazel labels stay typed until the private rule can declare them as sandbox inputs. """ + # These files use typed rule attributes below so the private rule can # pass their paths to the action. Add them to ``tools`` as well: that puts # the files in the Sphinx executable's runfiles (for Python-side lookup) @@ -203,6 +206,7 @@ def _bundle_needs_local_label(bundle): that implementation name directly. """ label = str(bundle) + # A package-local label is meaningful inside the BUILD file invoking the # macro. Turn it into an absolute workspace label before passing it to the # Python extension, which resolves inventory paths from Bazel runfiles. @@ -218,6 +222,7 @@ def _bundle_needs_local_label(bundle): ) package, target = label.rsplit(":", 1) + # Bundle callers name public targets. Keep generated implementation names # private as more internal targets are added over time. if "__internal__" in target: @@ -287,18 +292,18 @@ def _is_needs_inventory_target(label): return str(label).rsplit(":", 1)[-1] in ("needs_json", "needs_json_file") def _declare_docs_bundle( - name, - source_dir = None, - srcs = [], - data = [], - entry_doc = "index", - bundles = [], - code_targets = [], - primary_need_id = None, - root_docs_config = None, - is_root_bundle = False, - visibility = None, - **kwargs): + name, + source_dir = None, + srcs = [], + data = [], + entry_doc = "index", + bundles = [], + code_targets = [], + primary_need_id = None, + root_docs_config = None, + is_root_bundle = False, + visibility = None, + **kwargs): """Declare the shared bundle target implementation. This helper performs the bundle declaration used by both public entry @@ -364,6 +369,7 @@ def _declare_docs_bundle( # Keep directory-discovered sources separate from explicit Bazel targets so # each kind can retain its own runtime path and staging behavior. source_dir_globbed = glob_doc_sources(source_dir) if source_dir != None else [] + # The private file set is the single source of implementation artifacts. # Sourcelinks scan these same bounded files; consumers can inspect the # internal target without adding a field to the public bundle manifest. @@ -504,6 +510,7 @@ def _declare_bundle_local_needs( needs_local = _bundle_internal_target(name, "needs_local") needs_local_builder = _bundle_internal_target(name, "needs_local_builder") + # The source provider and local manifest describe the same owner-only # document set. Pass both to Sphinx so mounted descendants are neither # loaded as local sources nor assigned to this bundle's Needs export. @@ -543,17 +550,17 @@ def _declare_bundle_local_needs( ) def docs_bundle( - name, - source_dir = None, - srcs = [], - data = [], - entry_doc = "index", - bundles = [], - code_targets = [], - primary_need_id = None, - root_docs = None, - visibility = None, - **kwargs): + name, + source_dir = None, + srcs = [], + data = [], + entry_doc = "index", + bundles = [], + code_targets = [], + primary_need_id = None, + root_docs = None, + visibility = None, + **kwargs): """Declare a reusable documentation bundle. The declaration itself is delegated to the shared helper. Keeping this @@ -577,6 +584,7 @@ def docs_bundle( visibility = visibility, **kwargs ) + # The public bundle target above is composable and may contain nested # bundles. The local Needs inventory must instead use its source-only # sibling, so exported Needs reflect this bundle's ownership boundary. @@ -748,6 +756,7 @@ def docs( if config_is_missing: if not project or not project_url: fail("docs(): no " + config_file_path + " found; provide both project and project_url to docs().") + # Sphinx can run without a configuration file when ``-C`` is used. # Keep the macro's structured values as command-line overrides instead # of materializing a generated ``conf.py`` in the output tree. @@ -799,8 +808,9 @@ def docs( root_docs_config = root_docs_config, is_root_bundle = True, visibility = ["//visibility:public"], - tags = ["manual"] + tags = ["manual"], ) + # The runtime manifest must be generated from the actual root bundle. The # root entry carries the project's direct code_targets and gives Python a # complete composition snapshot alongside the nested mounts. @@ -808,6 +818,7 @@ def docs( name = "_mounts_manifest", bundle = ":docs_bundle", ) + # As with child docs_bundle targets, export Needs from the root's direct # source provider. Nested bundles are rendered by docs_bundle but keep # separate ownership and separate local Needs inventories. diff --git a/scripts_bazel/BUILD b/scripts_bazel/BUILD index 6140cc74c..781b239d4 100644 --- a/scripts_bazel/BUILD +++ b/scripts_bazel/BUILD @@ -36,9 +36,9 @@ py_binary( py_binary( name = "merge_sourcelinks", srcs = ["merge_sourcelinks.py"], - deps= [ "//src/extensions/score_source_code_linker"], main = "merge_sourcelinks.py", visibility = ["//visibility:public"], + deps = ["//src/extensions/score_source_code_linker"], ) py_binary( diff --git a/scripts_bazel/tests/BUILD b/scripts_bazel/tests/BUILD index 0569e42c4..6a103c50f 100644 --- a/scripts_bazel/tests/BUILD +++ b/scripts_bazel/tests/BUILD @@ -17,36 +17,36 @@ load("@score_tools//score_pytest:pytest.bzl", "score_pytest") score_pytest( name = "generate_sourcelinks_cli_test", srcs = ["generate_sourcelinks_cli_test.py"], + pytest_config = "//:pyproject.toml", deps = [ "//scripts_bazel:generate_sourcelinks", "//src/extensions/score_source_code_linker", ] + all_requirements, - pytest_config = "//:pyproject.toml", ) score_pytest( name = "merge_sourcelinks_test", srcs = ["merge_sourcelinks_test.py"], + pytest_config = "//:pyproject.toml", deps = [ "//scripts_bazel:merge_sourcelinks", ] + all_requirements, - pytest_config = "//:pyproject.toml", ) score_pytest( name = "merge_needs_json_tests", srcs = ["merge_needs_json_tests.py"], + pytest_config = "//:pyproject.toml", deps = [ "//scripts_bazel:merge_needs_json", ] + all_requirements, - pytest_config = "//:pyproject.toml", ) score_pytest( name = "traceability_gate_test", srcs = ["traceability_gate_test.py"], + pytest_config = "//:pyproject.toml", deps = [ "//scripts_bazel:traceability_gate", ] + all_requirements, - pytest_config = "//:pyproject.toml", ) diff --git a/src/BUILD b/src/BUILD index 2f88517ed..ba3466f64 100644 --- a/src/BUILD +++ b/src/BUILD @@ -40,12 +40,12 @@ filegroup( "//src/extensions/score_draw_uml_funcs:all_sources", "//src/extensions/score_layout:all_sources", "//src/extensions/score_metamodel:all_sources", + "//src/extensions/score_metrics:all_sources", "//src/extensions/score_mounts:all_sources", "//src/extensions/score_source_code_linker:all_sources", "//src/extensions/score_sphinx_bundle:all_sources", "//src/extensions/score_sphinx_needs_templates:all_sources", "//src/extensions/score_sync_toml:all_sources", - "//src/extensions/score_metrics:all_sources", "//src/helper_lib:all_sources", ], visibility = ["//visibility:public"], @@ -93,14 +93,14 @@ compile_pip_requirements( compile_pip_requirements( name = "requirements_py314", + srcs = [ + "requirements.in", + ], # Keep the Python version selector in pip-compile's generated header so # developers regenerate this lock with its matching toolchain. env = { "CUSTOM_COMPILE_COMMAND": "bazel run --@rules_python//python/config_settings:python_version=3.14 //src:requirements_py314.update", }, - srcs = [ - "requirements.in", - ], requirements_txt = "requirements_py314.txt", tags = [ "manual", diff --git a/src/docs_cli/BUILD b/src/docs_cli/BUILD index dc80923e6..c272a61bd 100644 --- a/src/docs_cli/BUILD +++ b/src/docs_cli/BUILD @@ -42,19 +42,22 @@ score_pytest( name = "lcov_summary_test", srcs = ["lcov_summary_test.py"], data = glob(["fixtures/*.info"]), - deps = [":lcov_summary_lib"], pytest_config = "//:pyproject.toml", + deps = [":lcov_summary_lib"], ) score_pytest( name = "dirty_build_test", - srcs = ["dirty_build_test.py", "cli.py"], + srcs = [ + "cli.py", + "dirty_build_test.py", + ], + pytest_config = "//:pyproject.toml", deps = all_requirements + [ + ":lcov_summary_lib", "//src/extensions/score_mounts", "//src/helper_lib", - ":lcov_summary_lib", ], - pytest_config = "//:pyproject.toml", ) # Exercise dispatch and the docs.bzl environment contract with the same @@ -62,11 +65,14 @@ score_pytest( # it distinct from score_pytest's own main.py entry in the test sources. score_pytest( name = "main_test", - srcs = ["main_test.py", "cli.py"], + srcs = [ + "cli.py", + "main_test.py", + ], + pytest_config = "//:pyproject.toml", deps = all_requirements + [ + ":lcov_summary_lib", "//src/extensions/score_mounts", "//src/helper_lib", - ":lcov_summary_lib", ], - pytest_config = "//:pyproject.toml", ) diff --git a/src/extensions/score_metamodel/BUILD b/src/extensions/score_metamodel/BUILD index d82af7d93..b65626589 100644 --- a/src/extensions/score_metamodel/BUILD +++ b/src/extensions/score_metamodel/BUILD @@ -57,8 +57,8 @@ py_library( # TODO: Figure out if all requirements are needed or if we can break it down a bit deps = all_requirements + [ "@score_docs_as_code//src/extensions/score_cross_module_compatibility", - "@score_docs_as_code//src/extensions/score_mounts", "@score_docs_as_code//src/extensions/score_metrics", + "@score_docs_as_code//src/extensions/score_mounts", "@score_docs_as_code//src/helper_lib", ], ) diff --git a/src/extensions/score_metamodel/docs/BUILD b/src/extensions/score_metamodel/docs/BUILD index 7632873a5..100e99790 100644 --- a/src/extensions/score_metamodel/docs/BUILD +++ b/src/extensions/score_metamodel/docs/BUILD @@ -11,9 +11,9 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -load("//:docs.bzl", "docs_bundle") load("@aspect_rules_py//py:defs.bzl", "py_binary") load("@docs_as_code_hub_env//:requirements.bzl", "all_requirements") +load("//:docs.bzl", "docs_bundle") genrule( name = "generate_metamodel_rst", @@ -36,8 +36,8 @@ py_binary( name = "generate_metamodel_rst_bin", srcs = ["generate_metamodel_rst.py"], main = "generate_metamodel_rst.py", + visibility = ["//visibility:public"], # public to be reuseable for other metamodels deps = all_requirements, - visibility = ["//visibility:public"], # public to be reuseable for other metamodels ) docs_bundle( diff --git a/src/extensions/score_metrics/BUILD b/src/extensions/score_metrics/BUILD index c08e1ef20..f297f5073 100644 --- a/src/extensions/score_metrics/BUILD +++ b/src/extensions/score_metrics/BUILD @@ -38,8 +38,8 @@ py_library( visibility = ["//visibility:public"], # TODO: Figure out if all requirements are needed or if we can break it down a bit deps = all_requirements + [ - "@score_docs_as_code//src/helper_lib", "@score_docs_as_code//src/extensions/score_sphinx_needs_templates", + "@score_docs_as_code//src/helper_lib", ], ) diff --git a/src/extensions/score_mounts/BUILD b/src/extensions/score_mounts/BUILD index 09495200d..6fc816e0e 100644 --- a/src/extensions/score_mounts/BUILD +++ b/src/extensions/score_mounts/BUILD @@ -50,6 +50,6 @@ score_pytest( name = "score_mounts_tests", size = "small", srcs = glob(["tests/*.py"]), - deps = [":score_mounts"], pytest_config = "//:pyproject.toml", + deps = [":score_mounts"], ) diff --git a/src/extensions/score_source_code_linker/BUILD b/src/extensions/score_source_code_linker/BUILD index 99984cf95..bee241512 100644 --- a/src/extensions/score_source_code_linker/BUILD +++ b/src/extensions/score_source_code_linker/BUILD @@ -51,11 +51,11 @@ py_library( py_library( name = "source_code_linker_helpers", srcs = [ + "helpers.py", "needlinks.py", + "repo_source_links.py", "testlink.py", "xml_parser.py", - "helpers.py", - "repo_source_links.py", ], imports = ["."], visibility = ["//visibility:public"], @@ -74,9 +74,9 @@ score_pytest( ], data = glob(["tests/*.json"]), imports = ["."], + pytest_config = "//:pyproject.toml", deps = [ ":score_source_code_linker", "//src/extensions/score_metamodel", ], - pytest_config = "//:pyproject.toml", ) diff --git a/src/extensions/score_sphinx_bundle/BUILD b/src/extensions/score_sphinx_bundle/BUILD index 6070f8966..312b886c9 100644 --- a/src/extensions/score_sphinx_bundle/BUILD +++ b/src/extensions/score_sphinx_bundle/BUILD @@ -24,17 +24,17 @@ py_library( srcs = [":all_sources"], visibility = ["//visibility:public"], deps = all_requirements + [ - "@score_docs_as_code//src/extensions:score_plantuml", - "@score_docs_as_code//src/extensions:score_coverage", "@score_docs_as_code//src/extensions:broken_link_fix", - "@score_docs_as_code//src/extensions/score_sphinx_needs_templates", - "@score_docs_as_code//src/extensions/score_draw_uml_funcs", + "@score_docs_as_code//src/extensions:score_coverage", + "@score_docs_as_code//src/extensions:score_plantuml", "@score_docs_as_code//src/extensions/score_cross_module_compatibility", + "@score_docs_as_code//src/extensions/score_draw_uml_funcs", "@score_docs_as_code//src/extensions/score_layout", "@score_docs_as_code//src/extensions/score_metamodel", + "@score_docs_as_code//src/extensions/score_metrics", "@score_docs_as_code//src/extensions/score_mounts", "@score_docs_as_code//src/extensions/score_source_code_linker", - "@score_docs_as_code//src/extensions/score_metrics", + "@score_docs_as_code//src/extensions/score_sphinx_needs_templates", "@score_docs_as_code//src/extensions/score_sync_toml", "@score_docs_as_code//src/helper_lib", ], diff --git a/src/extensions/score_sync_toml/BUILD b/src/extensions/score_sync_toml/BUILD index 69d16c103..2e6f54578 100644 --- a/src/extensions/score_sync_toml/BUILD +++ b/src/extensions/score_sync_toml/BUILD @@ -12,8 +12,8 @@ # ******************************************************************************* load("@aspect_rules_py//py:defs.bzl", "py_library") -load("@score_tools//score_pytest:pytest.bzl", "score_pytest") load("@docs_as_code_hub_env//:requirements.bzl", "requirement") +load("@score_tools//score_pytest:pytest.bzl", "score_pytest") filegroup( name = "all_sources", @@ -40,6 +40,6 @@ score_pytest( name = "score_sync_toml_tests", size = "small", srcs = ["test_mounts.py"], - deps = [":score_sync_toml"], pytest_config = "//:pyproject.toml", + deps = [":score_sync_toml"], ) diff --git a/src/helper_lib/BUILD b/src/helper_lib/BUILD index 5430d81a3..4e11ab95d 100644 --- a/src/helper_lib/BUILD +++ b/src/helper_lib/BUILD @@ -34,8 +34,8 @@ score_pytest( name = "helper_lib_tests", size = "small", srcs = ["test_helper_lib.py"], + pytest_config = "//:pyproject.toml", deps = [ ":helper_lib", ] + all_requirements, - pytest_config = "//:pyproject.toml", ) diff --git a/src/tests/docs_bzl/cross_module_fixture/BUILD b/src/tests/docs_bzl/cross_module_fixture/BUILD index 59fd03761..3e8972dba 100644 --- a/src/tests/docs_bzl/cross_module_fixture/BUILD +++ b/src/tests/docs_bzl/cross_module_fixture/BUILD @@ -14,7 +14,7 @@ load("@score_docs_as_code//:docs.bzl", "docs") docs( - source_dir = "docs", project = "Score Docs Compatibility Fixture", project_url = "https://eclipse-score.github.io/docs-as-code", + source_dir = "docs", ) diff --git a/src/tests/docs_bzl/cross_module_fixture/MODULE.bazel b/src/tests/docs_bzl/cross_module_fixture/MODULE.bazel index 6b9083d3e..98b70f62c 100644 --- a/src/tests/docs_bzl/cross_module_fixture/MODULE.bazel +++ b/src/tests/docs_bzl/cross_module_fixture/MODULE.bazel @@ -11,6 +11,9 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -module(name = "score_docs_compatibility_fixture", version = "0.0.1") +module( + name = "score_docs_compatibility_fixture", + version = "0.0.1", +) bazel_dep(name = "score_docs_as_code", version = "4.6.0") diff --git a/src/tests/docs_bzl/scenarios/basic_docs/BUILD b/src/tests/docs_bzl/scenarios/basic_docs/BUILD index 9a076f759..9a33fa443 100644 --- a/src/tests/docs_bzl/scenarios/basic_docs/BUILD +++ b/src/tests/docs_bzl/scenarios/basic_docs/BUILD @@ -14,9 +14,9 @@ load("//:docs.bzl", "docs") docs( - source_dir = "docs", + data = ["supporting-example.txt"], project = "Basic Test", project_url = "https://github.com/eclipse-score/docs-as-code", - data = ["supporting-example.txt"], + source_dir = "docs", test_sources = ["src/tests/docs_bzl/scenarios/basic_docs"], ) diff --git a/src/tests/docs_bzl/scenarios/coverage_summary/BUILD b/src/tests/docs_bzl/scenarios/coverage_summary/BUILD index 20a32500f..6768b41d0 100644 --- a/src/tests/docs_bzl/scenarios/coverage_summary/BUILD +++ b/src/tests/docs_bzl/scenarios/coverage_summary/BUILD @@ -13,38 +13,78 @@ load("//:docs.bzl", "docs_bundle") -filegroup(name = "files", srcs = ["a.cc"]) +filegroup( + name = "files", + srcs = ["a.cc"], +) # Each primary Need is declared in its bundle's own documentation. Selecting # an external code target retains those implementation files' repository. docs_bundle( name = "component", srcs = ["component/index.rst"], - code_targets = [":files", "@bazel_tools//tools/cpp/runfiles:runfiles"], + code_targets = [ + ":files", + "@bazel_tools//tools/cpp/runfiles:runfiles", + ], primary_need_id = "comp__files", ) -docs_bundle(name = "empty", srcs = ["empty/index.rst"], primary_need_id = "mod__empty") -docs_bundle(name = "unidentified", code_targets = [":files"]) +docs_bundle( + name = "empty", + srcs = ["empty/index.rst"], + primary_need_id = "mod__empty", +) + +docs_bundle( + name = "unidentified", + code_targets = [":files"], +) # Propagate the component through an intermediate source-less aggregator. -docs_bundle(name = "left", bundles = [{"bundle": ":component", "mount_at": "code"}]) +docs_bundle( + name = "left", + bundles = [{ + "bundle": ":component", + "mount_at": "code", + }], +) docs_bundle( name = "aggregate", bundles = [ - {"bundle": ":left", "mount_at": "first"}, - {"bundle": ":empty", "mount_at": "empty"}, - {"bundle": ":unidentified", "mount_at": "unidentified"}, + { + "bundle": ":left", + "mount_at": "first", + }, + { + "bundle": ":empty", + "mount_at": "empty", + }, + { + "bundle": ":unidentified", + "mount_at": "unidentified", + }, ], ) # Two different bundles must not silently overwrite ownership for the same ID. -docs_bundle(name = "conflicting", srcs = ["conflicting/index.rst"], primary_need_id = "comp__files") +docs_bundle( + name = "conflicting", + srcs = ["conflicting/index.rst"], + primary_need_id = "comp__files", +) + docs_bundle( name = "conflict", bundles = [ - {"bundle": ":component", "mount_at": "first"}, - {"bundle": ":conflicting", "mount_at": "second"}, + { + "bundle": ":component", + "mount_at": "first", + }, + { + "bundle": ":conflicting", + "mount_at": "second", + }, ], ) diff --git a/src/tests/docs_bzl/scenarios/data_files_runfiles/BUILD b/src/tests/docs_bzl/scenarios/data_files_runfiles/BUILD index b8f0e4cd4..b6164b552 100644 --- a/src/tests/docs_bzl/scenarios/data_files_runfiles/BUILD +++ b/src/tests/docs_bzl/scenarios/data_files_runfiles/BUILD @@ -67,25 +67,29 @@ docs_bundle( ) docs( + bundles = [ + { + "bundle": ":data_bundle", + "mount_at": "data_test", + "attach_to": "index", + }, + { + "bundle": ":legacy_data_bundle", + "mount_at": "legacy_data_test", + "attach_to": "index", + }, + { + "bundle": ":isolated_source_bundle", + "mount_at": "isolated_test", + "attach_to": "index", + }, + ], source_dir = "docs", # Keep this fixture's test-source scope local. The default imports every # test report in the repository, including unrelated external-link # warnings that would make this focused runtime scenario fail as an # accidental side effect of the global test corpus. test_sources = ["src/tests/docs_bzl/scenarios/data_files_runfiles"], - bundles = [{ - "bundle": ":data_bundle", - "mount_at": "data_test", - "attach_to": "index", - }, { - "bundle": ":legacy_data_bundle", - "mount_at": "legacy_data_test", - "attach_to": "index", - }, { - "bundle": ":isolated_source_bundle", - "mount_at": "isolated_test", - "attach_to": "index", - }], ) # END docs-bundle-howto: generated-data diff --git a/src/tests/docs_bzl/scenarios/deprecated_needs_data/BUILD b/src/tests/docs_bzl/scenarios/deprecated_needs_data/BUILD index 4b72a6f6c..8430f00d0 100644 --- a/src/tests/docs_bzl/scenarios/deprecated_needs_data/BUILD +++ b/src/tests/docs_bzl/scenarios/deprecated_needs_data/BUILD @@ -17,10 +17,10 @@ load("//:docs.bzl", "docs") # other test builds its targets, so the package-loading message can be checked # without depending on Bazel printing it again for an already-loaded package. docs( - source_dir = "docs", - project = "Deprecated Needs Data Input", - project_url = "https://example.invalid/deprecated-needs-data-input", data = [ "//src/tests/docs_bzl/scenarios/reference_integration/score_platform:needs_json_file", ], + project = "Deprecated Needs Data Input", + project_url = "https://example.invalid/deprecated-needs-data-input", + source_dir = "docs", ) diff --git a/src/tests/docs_bzl/scenarios/external_bundle/BUILD b/src/tests/docs_bzl/scenarios/external_bundle/BUILD index 2a1f85c6f..b3d36d906 100644 --- a/src/tests/docs_bzl/scenarios/external_bundle/BUILD +++ b/src/tests/docs_bzl/scenarios/external_bundle/BUILD @@ -18,11 +18,11 @@ load("//:docs.bzl", "docs") # than silently omitting it. # BEGIN docs-bundle-howto: external-bundle docs( - source_dir = "host_docs", - test_sources = ["src/tests/docs_bzl/scenarios/external_bundle"], bundles = [{ "bundle": "@score_process_description//:docs_bundle", "mount_at": "process", }], + source_dir = "host_docs", + test_sources = ["src/tests/docs_bzl/scenarios/external_bundle"], ) # END docs-bundle-howto: external-bundle diff --git a/src/tests/docs_bzl/scenarios/external_needs_inputs/BUILD b/src/tests/docs_bzl/scenarios/external_needs_inputs/BUILD index 64dc8aefd..1155117ec 100644 --- a/src/tests/docs_bzl/scenarios/external_needs_inputs/BUILD +++ b/src/tests/docs_bzl/scenarios/external_needs_inputs/BUILD @@ -17,10 +17,6 @@ load("//:docs.bzl", "docs") # runtime test load a public docs_bundle export and a needs_json_file from # different packages without importing the same Need twice. docs( - source_dir = "docs", - project = "External Needs Inputs", - project_url = "https://example.invalid/external-needs-inputs", - test_sources = ["src/tests/docs_bzl/scenarios/external_needs_inputs"], external_needs = [ # A docs() label resolves to that producer's local Needs inventory. "//src/tests/docs_bzl/scenarios/reference_integration/score_platform:docs", @@ -29,4 +25,8 @@ docs( # A direct inventory file label remains supported for non-bundle inputs. "//src/tests/docs_bzl/scenarios/subdirectory_bundle/producer:needs_json_file", ], + project = "External Needs Inputs", + project_url = "https://example.invalid/external-needs-inputs", + source_dir = "docs", + test_sources = ["src/tests/docs_bzl/scenarios/external_needs_inputs"], ) diff --git a/src/tests/docs_bzl/scenarios/invalid_bundle_placements/BUILD b/src/tests/docs_bzl/scenarios/invalid_bundle_placements/BUILD index 82dc36edf..39e9098a9 100644 --- a/src/tests/docs_bzl/scenarios/invalid_bundle_placements/BUILD +++ b/src/tests/docs_bzl/scenarios/invalid_bundle_placements/BUILD @@ -14,53 +14,73 @@ load("//:docs.bzl", "docs_bundle") docs_bundle( name = "child", - source_dir = "child", entry_doc = "a", + source_dir = "child", ) docs_bundle( name = "wrapper_x", - source_dir = "_empty", bundles = [ - {"bundle": ":child", "mount_at": "x"}, + { + "bundle": ":child", + "mount_at": "x", + }, ], + source_dir = "_empty", ) docs_bundle( name = "wrapper_y", - source_dir = "_empty", bundles = [ - {"bundle": ":child", "mount_at": "y"}, + { + "bundle": ":child", + "mount_at": "y", + }, ], + source_dir = "_empty", ) # These wrappers have the same final document location, but disagree about # metadata that the manifest can represent only once. docs_bundle( name = "attach_to_a", - source_dir = "_empty", bundles = [ - {"bundle": ":child", "mount_at": "same", "attach_to": "a/index"}, + { + "bundle": ":child", + "mount_at": "same", + "attach_to": "a/index", + }, ], + source_dir = "_empty", ) docs_bundle( name = "attach_to_b", - source_dir = "_empty", bundles = [ - {"bundle": ":child", "mount_at": "same", "attach_to": "b/index"}, + { + "bundle": ":child", + "mount_at": "same", + "attach_to": "b/index", + }, ], + source_dir = "_empty", ) # The child reaches the final bundle at two different locations, so analysis # must stop before Sphinx would receive two copies of the same pages. docs_bundle( name = "bad", - source_dir = "_empty", bundles = [ - {"bundle": ":wrapper_x", "mount_at": "root"}, - {"bundle": ":wrapper_y", "mount_at": "root"}, + { + "bundle": ":wrapper_x", + "mount_at": "root", + }, + { + "bundle": ":wrapper_y", + "mount_at": "root", + }, ], + source_dir = "_empty", # Tagged manual so `bazel build //...` never expands to it; # the test builds it explicitly and asserts the analysis error. tags = ["manual"], @@ -68,10 +88,16 @@ docs_bundle( docs_bundle( name = "bad_attach_to", - source_dir = "_empty", bundles = [ - {"bundle": ":attach_to_a", "mount_at": "root"}, - {"bundle": ":attach_to_b", "mount_at": "root"}, + { + "bundle": ":attach_to_a", + "mount_at": "root", + }, + { + "bundle": ":attach_to_b", + "mount_at": "root", + }, ], + source_dir = "_empty", tags = ["manual"], ) diff --git a/src/tests/docs_bzl/scenarios/nested_bundles/BUILD b/src/tests/docs_bzl/scenarios/nested_bundles/BUILD index 3e1f51438..3338ce0fd 100644 --- a/src/tests/docs_bzl/scenarios/nested_bundles/BUILD +++ b/src/tests/docs_bzl/scenarios/nested_bundles/BUILD @@ -11,19 +11,19 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* +load("@aspect_rules_py//py:defs.bzl", "py_binary") load("//:bzl/mount_rules.bzl", "create_composition_manifest") load("//:docs.bzl", "docs", "docs_bundle") -load("@aspect_rules_py//py:defs.bzl", "py_binary") docs_bundle( name = "child", - source_dir = "child", - entry_doc = "landing", code_targets = [ ":example_binary", ":example_executable", ":nested_filegroup_sources", ], + entry_doc = "landing", + source_dir = "child", ) filegroup( @@ -67,12 +67,12 @@ cc_binary( # BEGIN docs-bundle-howto: parent-composition docs_bundle( name = "parent", - source_dir = "parent", bundles = [{ "bundle": ":child", "mount_at": "child", }], data = [":generated_doc_output"], + source_dir = "parent", visibility = ["//visibility:public"], ) # END docs-bundle-howto: parent-composition @@ -82,8 +82,14 @@ docs_bundle( docs_bundle( name = "ordered_aggregate", bundles = [ - {"bundle": ":other", "mount_at": "first"}, - {"bundle": ":child", "mount_at": "second"}, + { + "bundle": ":other", + "mount_at": "first", + }, + { + "bundle": ":child", + "mount_at": "second", + }, ], ) @@ -100,13 +106,13 @@ create_composition_manifest( # A complete docs() invocation is the synthetic host project driven by the # pytest integration test in //src/tests/docs_bzl. docs( - source_dir = "host_docs", - code_targets = [":example_binary"], - test_sources = ["src/tests/docs_bzl/scenarios/nested_bundles"], bundles = [{ "bundle": ":parent", "mount_at": "concepts/example_bundle", # Attach to the second toctree (index 1) of concepts/index.rst. "toctree_index": 1, }], + code_targets = [":example_binary"], + source_dir = "host_docs", + test_sources = ["src/tests/docs_bzl/scenarios/nested_bundles"], ) diff --git a/src/tests/docs_bzl/scenarios/reference_integration/legacy_module/BUILD b/src/tests/docs_bzl/scenarios/reference_integration/legacy_module/BUILD index 4e645a0e4..411ec715d 100644 --- a/src/tests/docs_bzl/scenarios/reference_integration/legacy_module/BUILD +++ b/src/tests/docs_bzl/scenarios/reference_integration/legacy_module/BUILD @@ -27,17 +27,17 @@ load("//:docs.bzl", "docs") # The component package is physically below this module's ``docs`` source tree, # so the module's primary Sphinx walk must leave ownership to the child mount. docs( - project = "S-CORE Legacy Module", - project_url = "https://example.invalid/score-legacy-module", - source_dir = "docs", - test_sources = ["src/tests/docs_bzl/scenarios/reference_integration"], - data = [ - "//src/tests/docs_bzl/scenarios/reference_integration/score_platform:needs_json_file", - "@score_process_description//:needs_json", - ], bundles = [{ "bundle": "//src/tests/docs_bzl/scenarios/reference_integration/legacy_module/docs/components/component:docs_bundle", "mount_at": "components/component", "attach_to": "components", }], + data = [ + "//src/tests/docs_bzl/scenarios/reference_integration/score_platform:needs_json_file", + "@score_process_description//:needs_json", + ], + project = "S-CORE Legacy Module", + project_url = "https://example.invalid/score-legacy-module", + source_dir = "docs", + test_sources = ["src/tests/docs_bzl/scenarios/reference_integration"], ) diff --git a/src/tests/docs_bzl/scenarios/reference_integration/legacy_module/docs/components/component/BUILD b/src/tests/docs_bzl/scenarios/reference_integration/legacy_module/docs/components/component/BUILD index 9fdd2f011..ebfd23b06 100644 --- a/src/tests/docs_bzl/scenarios/reference_integration/legacy_module/docs/components/component/BUILD +++ b/src/tests/docs_bzl/scenarios/reference_integration/legacy_module/docs/components/component/BUILD @@ -26,8 +26,8 @@ docs_bundle( # Deliberately keep the Bazel target name independent from the Need ID. # The explicit primary_need_id is the only association used for metadata. name = "docs_bundle", - source_dir = ".", code_targets = [":component_sources"], primary_need_id = "tool_req__legacy_component", + source_dir = ".", visibility = ["//visibility:public"], ) diff --git a/src/tests/docs_bzl/scenarios/reference_integration/modern_module/BUILD b/src/tests/docs_bzl/scenarios/reference_integration/modern_module/BUILD index 43da4e4b9..9c8f49d8a 100644 --- a/src/tests/docs_bzl/scenarios/reference_integration/modern_module/BUILD +++ b/src/tests/docs_bzl/scenarios/reference_integration/modern_module/BUILD @@ -20,21 +20,24 @@ load("//:docs.bzl", "docs") # exercises the distinction between a component that needs its parent bundle's # external Needs and one that can be built independently. docs( - project = "S-CORE Modern Module", - project_url = "https://example.invalid/score-modern-module", - source_dir = "docs", - test_sources = ["src/tests/docs_bzl/scenarios/reference_integration"], + bundles = [ + { + "bundle": "//src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/component:docs_bundle", + "mount_at": "components/component", + "attach_to": "components", + }, + { + "bundle": "//src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/unlinked_component:docs_bundle", + "mount_at": "components/unlinked_component", + "attach_to": "components", + }, + ], external_needs = [ "//src/tests/docs_bzl/scenarios/reference_integration/score_platform:needs_json", "@score_process_description//:needs_json", ], - bundles = [{ - "bundle": "//src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/component:docs_bundle", - "mount_at": "components/component", - "attach_to": "components", - }, { - "bundle": "//src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/unlinked_component:docs_bundle", - "mount_at": "components/unlinked_component", - "attach_to": "components", - }], + project = "S-CORE Modern Module", + project_url = "https://example.invalid/score-modern-module", + source_dir = "docs", + test_sources = ["src/tests/docs_bzl/scenarios/reference_integration"], ) diff --git a/src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/component/BUILD b/src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/component/BUILD index 69edb6708..f3de05bde 100644 --- a/src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/component/BUILD +++ b/src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/component/BUILD @@ -72,12 +72,12 @@ docs_bundle( # The component Need is selected explicitly even though this page contains # feature, component, requirement, and tool Needs. name = "docs_bundle", - source_dir = ".", code_targets = [ ":component_sources", ":implementation", ], primary_need_id = "comp__modern_component", + source_dir = ".", visibility = ["//visibility:public"], ) diff --git a/src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/unlinked_component/BUILD b/src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/unlinked_component/BUILD index f7edeca5a..ed4b696fe 100644 --- a/src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/unlinked_component/BUILD +++ b/src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/unlinked_component/BUILD @@ -52,11 +52,11 @@ docs_bundle( # still covers the standalone Needs export. docs_bundle( name = "docs_bundle", - source_dir = ".", bundles = [{ "bundle": ":generated_metamodel", "mount_at": "generated_metamodel", }], + source_dir = ".", visibility = ["//visibility:public"], ) @@ -66,9 +66,9 @@ cc_library( name = "implementation", srcs = ["implementation.cc"], hdrs = [":public_headers"], + visibility = ["//visibility:public"], # This dependency returns to the linked component's package subtree. deps = ["//src/tests/docs_bzl/scenarios/reference_integration/modern_module/docs/components/component/detail:support"], - visibility = ["//visibility:public"], ) filegroup( @@ -82,6 +82,6 @@ filegroup( cc_library( name = "api", hdrs = [":public_headers"], - deps = [":implementation"], visibility = ["//visibility:public"], + deps = [":implementation"], ) diff --git a/src/tests/docs_bzl/scenarios/root_docs_config/BUILD b/src/tests/docs_bzl/scenarios/root_docs_config/BUILD index e427b5a76..a91accb16 100644 --- a/src/tests/docs_bzl/scenarios/root_docs_config/BUILD +++ b/src/tests/docs_bzl/scenarios/root_docs_config/BUILD @@ -17,14 +17,14 @@ load("//:docs.bzl", "docs", "docs_bundle") # conf.py deliberately contains a value that must not cross the root-docs # configuration boundary. docs( - source_dir = "platform", - project = "Root docs configuration fixture", - project_url = "https://example.invalid/root-docs-config", - metamodel = ":metamodel.yaml", bundles = [{ "bundle": ":component", "mount_at": "component", }], + metamodel = ":metamodel.yaml", + project = "Root docs configuration fixture", + project_url = "https://example.invalid/root-docs-config", + source_dir = "platform", ) # The child has no conf.py of its own. Its Needs export must receive the root @@ -32,8 +32,8 @@ docs( # through the independent internal config target. docs_bundle( name = "component", - source_dir = "component", root_docs = "//src/tests/docs_bzl/scenarios/root_docs_config:docs", + source_dir = "component", ) # This bundle's Need ID is valid only when the root's legacy conf.py is @@ -41,6 +41,6 @@ docs_bundle( # root-docs configuration interface. docs_bundle( name = "conf_sensitive_child", - source_dir = "conf_sensitive_child", root_docs = "//src/tests/docs_bzl/scenarios/root_docs_config:docs", + source_dir = "conf_sensitive_child", ) diff --git a/src/tests/docs_bzl/scenarios/subdirectory_bundle/consumer/BUILD b/src/tests/docs_bzl/scenarios/subdirectory_bundle/consumer/BUILD index c5323288c..355f47cc9 100644 --- a/src/tests/docs_bzl/scenarios/subdirectory_bundle/consumer/BUILD +++ b/src/tests/docs_bzl/scenarios/subdirectory_bundle/consumer/BUILD @@ -17,12 +17,12 @@ load("//:docs.bzl", "docs") # transitive bundle assembled by producer/docs(), including its subdirectory # bundle, without adding the producer's needs_json separately. docs( - source_dir = "docs", - project = "Subdirectory Bundle Consumer", - project_url = "https://example.invalid/subdirectory-bundle-consumer", - test_sources = ["src/tests/docs_bzl/scenarios/subdirectory_bundle/consumer"], bundles = [{ "bundle": "//src/tests/docs_bzl/scenarios/subdirectory_bundle/producer:docs_bundle", "mount_at": "producer", }], + project = "Subdirectory Bundle Consumer", + project_url = "https://example.invalid/subdirectory-bundle-consumer", + source_dir = "docs", + test_sources = ["src/tests/docs_bzl/scenarios/subdirectory_bundle/consumer"], ) diff --git a/src/tests/docs_bzl/scenarios/subdirectory_bundle/producer/BUILD b/src/tests/docs_bzl/scenarios/subdirectory_bundle/producer/BUILD index a412bf165..4c0aa0695 100644 --- a/src/tests/docs_bzl/scenarios/subdirectory_bundle/producer/BUILD +++ b/src/tests/docs_bzl/scenarios/subdirectory_bundle/producer/BUILD @@ -16,12 +16,12 @@ load("//:docs.bzl", "docs") # The embedded bundle lives in a nested package below the docs source. # The parent docs() must mount it explicitly because it is a separate package. docs( - source_dir = "docs", - project = "Subdirectory Bundle Producer", - project_url = "https://example.invalid/subdirectory-bundle-producer", - test_sources = ["src/tests/docs_bzl/scenarios/subdirectory_bundle/producer"], bundles = [{ "bundle": "//src/tests/docs_bzl/scenarios/subdirectory_bundle/producer/docs/embedded:docs_bundle", "mount_at": "embedded", }], + project = "Subdirectory Bundle Producer", + project_url = "https://example.invalid/subdirectory-bundle-producer", + source_dir = "docs", + test_sources = ["src/tests/docs_bzl/scenarios/subdirectory_bundle/producer"], ) diff --git a/tools/tests/BUILD b/tools/tests/BUILD index f3f994321..c5a8e91e0 100644 --- a/tools/tests/BUILD +++ b/tools/tests/BUILD @@ -17,9 +17,9 @@ load("@score_tools//score_pytest:pytest.bzl", "score_pytest") score_pytest( name = "module_verification_reports_test", srcs = ["module_verification_reports_test.py"], + pytest_config = "//:pyproject.toml", deps = [ - "//tools:module_verification_reports", "//src/helper_lib", + "//tools:module_verification_reports", ] + all_requirements, - pytest_config = "//:pyproject.toml", ) From 9ec2564e1e90b49826745ed6bf19b47c8557724c Mon Sep 17 00:00:00 2001 From: Alexander Lanin Date: Mon, 2 Nov 2026 14:05:55 +0100 Subject: [PATCH 2/2] fix: regenerate module lockfile with Bazel 8.8.2 --- MODULE.bazel.lock | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 3dee19ada..50e03ef41 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -399,11 +399,12 @@ }, "@@buildifier_prebuilt+//:defs.bzl%buildifier_prebuilt_deps_extension": { "general": { - "bzlTransitiveDigest": "UuPPKtgkayflJh3xnoDcElnjA0xyLYaim0cMSFV12v8=", + "bzlTransitiveDigest": "7bCbBwC3B6yFaJpQDhFyYirer+5U+YbfUb6OGRC+ZBo=", "usagesDigest": "eWMDBEn8E8CrwAPXrlrjIap2pseSMhxDyDdrntHBOOE=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, + "recordedInputs": [ + "REPO_MAPPING:buildifier_prebuilt+,bazel_skylib bazel_skylib+", + "REPO_MAPPING:buildifier_prebuilt+,bazel_tools bazel_tools" + ], "generatedRepoSpecs": { "buildifier_darwin_amd64": { "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", @@ -521,19 +522,7 @@ "assets_json": "[{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"darwin\",\"sha256\":\"375f823103d01620aaec20a0c29c6cbca99f4fd0725ae30b93655c6704f44d71\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildifier\",\"platform\":\"darwin\",\"sha256\":\"5a6afc6ac7a09f5455ba0b89bd99d5ae23b4174dc5dc9d6c0ed5ce8caac3f813\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"linux\",\"sha256\":\"5474cc5128a74e806783d54081f581662c4be8ae65022f557e9281ed5dc88009\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildifier\",\"platform\":\"linux\",\"sha256\":\"0bf86c4bfffaf4f08eed77bde5b2082e4ae5039a11e2e8b03984c173c34a561c\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"windows\",\"sha256\":\"370cd576075ad29930a82f5de132f1a1de4084c784a82514bd4da80c85acf4a8\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"darwin\",\"sha256\":\"854c9583efc166602276802658cef3f224d60898cfaa60630b33d328db3b0de2\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildozer\",\"platform\":\"darwin\",\"sha256\":\"31b1bfe20d7d5444be217af78f94c5c43799cdf847c6ce69794b7bf3319c5364\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"linux\",\"sha256\":\"3305e287b3fcc68b9a35fd8515ee617452cd4e018f9e6886b6c7cdbcba8710d4\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildozer\",\"platform\":\"linux\",\"sha256\":\"0b5a2a717ac4fc911e1fec8d92af71dbb4fe95b10e5213da0cc3d56cea64a328\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"windows\",\"sha256\":\"58d41ce53257c5594c9bc86d769f580909269f68de114297f46284fbb9023dcf\",\"version\":\"v7.3.1\"}]" } } - }, - "recordedRepoMappingEntries": [ - [ - "buildifier_prebuilt+", - "bazel_skylib", - "bazel_skylib+" - ], - [ - "buildifier_prebuilt+", - "bazel_tools", - "bazel_tools" - ] - ] + } } }, "@@pybind11_bazel+//:python_configure.bzl%extension": {