Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ filegroup(
"//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",
Expand Down
5 changes: 5 additions & 0 deletions src/extensions/score_metamodel/metamodel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,11 @@ needs_types:
- verification_report
parts: 3

auto_mod_ver_report:
title: Module Verification Report (automated)
parts: 2
mandatory_links:
belongs_to: mod

# https://eclipse-score.github.io/process_description/main/permalink.html?id=gd_temp__change_decision_record
dec_rec:
Expand Down
5 changes: 1 addition & 4 deletions src/extensions/score_sphinx_bundle/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ filegroup(
py_library(
name = "score_sphinx_bundle",
srcs = [":all_sources"],
# Keep the shared Sphinx-Needs templates beside the extension in the
# Bazel runfiles tree. The Python extension discovers their directory from
# its own __file__ instead of receiving a path from docs.bzl.
data = ["@score_docs_as_code//src/needs_templates:files"],
visibility = ["//visibility:public"],
deps = all_requirements + [
"@score_docs_as_code//src/extensions:score_plantuml",
"@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_cross_module_compatibility",
"@score_docs_as_code//src/extensions/score_layout",
Expand Down
29 changes: 1 addition & 28 deletions src/extensions/score_sphinx_bundle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
from pathlib import Path

import matplotlib
from sphinx.application import Sphinx

Expand All @@ -24,6 +22,7 @@
"sphinxcontrib.plantuml",
"score_plantuml",
"sphinx_needs",
"score_sphinx_needs_templates",
"score_cross_module_compatibility",
"score_metamodel",
"sphinx_design",
Expand All @@ -45,38 +44,12 @@
]


def _needs_template_folder() -> Path:
"""Return the shared Sphinx-Needs template directory.

The extension and the templates are both part of the main ``src`` tree.
Deriving the path from ``__file__`` works for the workspace, Bazel
runfiles, and the sandbox because the extension's data files preserve that
source-tree layout.
"""
# Keep the runfiles/sandbox prefix intact; only walk from the extension's
# package directory to the sibling ``needs_templates`` directory.
# Basically: src/extensions/score_sphinx_bundle/../../needs_templates.
template_folder = Path(__file__).parents[2] / "needs_templates"
if not template_folder.is_dir():
raise FileNotFoundError(
f"Sphinx-Needs template folder does not exist: {template_folder}"
)
return template_folder


def setup(app: Sphinx) -> dict[str, object]:
matplotlib.rcParamsDefault["savefig.bbox"] = "tight"

config_setdefault(app.config, "html_copy_source", False)
config_setdefault(app.config, "html_show_sourcelink", False)

# The templates are a data dependency of this extension. Locate the
# shared directory from the extension itself instead of passing a Bazel
# label or a list of generated paths through every docs target.
config_setdefault(
app.config, "needs_template_folder", str(_needs_template_folder())
)

# Global settings
# Note: the "sub-extensions" also set their own config values

Expand Down
30 changes: 30 additions & 0 deletions src/extensions/score_sphinx_needs_templates/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@aspect_rules_py//py:defs.bzl", "py_library")
load("@docs_as_code_hub_env//:requirements.bzl", "all_requirements")

filegroup(
name = "all_sources",
srcs = ["__init__.py"],
visibility = ["//visibility:public"],
)

py_library(
name = "score_sphinx_needs_templates",
srcs = [":all_sources"],
data = ["@score_docs_as_code//src/needs_templates:files"],
visibility = ["//visibility:public"],
deps = all_requirements + [
"@score_docs_as_code//src/helper_lib",
],
)
48 changes: 48 additions & 0 deletions src/extensions/score_sphinx_needs_templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!-- ----------------------------------------------------------------------------
Copyright (c) 2026 Contributors to the Eclipse Foundation

See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-License-Identifier: Apache-2.0
----------------------------------------------------------------------------- -->

# `score_sphinx_needs_templates`

This extension contains the runtime support for the repository's Sphinx-Needs
`.need` templates. It is loaded by `score_sphinx_bundle` immediately after
`sphinx_needs`.

## Features

The extension provides:

* the shared `src/needs_templates` directory as the Sphinx-Needs template
directory;
* the `linked_needs(need_id, link_name)` helper for traversing Need links;
* support for templates whose output depends on other Needs in the model;
* local page navigation for headings generated by marked templates.

## Using `linked_needs`

The helper returns the linked `NeedItem` objects in the order declared by the
source Need. This allows a template to derive its sections from the Need graph
instead of embedding Need IDs.

For example:

```jinja
{# score: render-after-needs-collection #}
{% set components = linked_needs(module_id, "includes") %}
{% for component in components %}
{{ component["title"] }}
{% endfor %}
```

Templates that follow links across the Need model should include the
`score: render-after-needs-collection` marker in a Jinja comment. Need fields and filters
continue to expose the corresponding backlink fields with the `_back` suffix.
Loading
Loading