Skip to content

Commit 7f364c8

Browse files
template: integrate docs-as-code (#15)
* template: integrate docs-as-code * docs: fixed formatting Use the `docs-as-code` tool for building documentation fixed formatting issues Addresses: eclipse-score/score#926 --------- Signed-off-by: Dan Calavrezo <[email protected]>
1 parent fe3a7b8 commit 7f364c8

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed

MODULE.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ bazel_dep(name = "score_dash_license_checker", version = "0.1.1")
6060
bazel_dep(name = "score_format_checker", version = "0.1.1")
6161
bazel_dep(name = "aspect_rules_lint", version = "1.0.3")
6262
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1")
63+
64+
#docs-as-code
65+
bazel_dep(name = "score_docs_as_code", version = "0.2.1")

docs/BUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("@score_docs_as_code//:docs.bzl", "docs")
2+
3+
# Creates all documentation targets:
4+
# - `docs:incremental` for building docs incrementally at runtime
5+
# - `docs:live_preview` for live preview in the browser without an IDE
6+
# - `docs:ide_support` for creating python virtualenv for IDE support
7+
# - `docs:docs` for building documentation at build-time
8+
9+
docs(
10+
# conf_dir = "docs",
11+
docs_targets = [
12+
{
13+
"suffix": "", # local without external needs
14+
},
15+
],
16+
# source_dir = "docs",
17+
source_files_to_scan_for_needs_links = [],
18+
)

docs/conf.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
# Configuration file for the Sphinx documentation builder.
15+
#
16+
# For the full list of built-in configuration values, see the documentation:
17+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
18+
19+
20+
# -- Project information -----------------------------------------------------
21+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
22+
23+
project = "Module Template Project"
24+
author = "S-CORE"
25+
version = "0.1"
26+
27+
# -- General configuration ---------------------------------------------------
28+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
29+
30+
31+
extensions = [
32+
"sphinx_design",
33+
"sphinx_needs",
34+
"sphinxcontrib.plantuml",
35+
"score_plantuml",
36+
"score_metamodel",
37+
"score_draw_uml_funcs",
38+
"score_source_code_linker",
39+
"score_layout",
40+
]
41+
42+
exclude_patterns = [
43+
# The following entries are not required when building the documentation via 'bazel
44+
# build //docs:docs', as that command runs in a sandboxed environment. However, when
45+
# building the documentation via 'bazel run //docs:incremental' or esbonio, these
46+
# entries are required to prevent the build from failing.
47+
"bazel-*",
48+
".venv_docs",
49+
]
50+
51+
templates_path = ["templates"]
52+
53+
# Enable numref
54+
numfig = True

docs/index.rst

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
..
2+
# *******************************************************************************
3+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
4+
#
5+
# See the NOTICE file(s) distributed with this work for additional
6+
# information regarding copyright ownership.
7+
#
8+
# This program and the accompanying materials are made available under the
9+
# terms of the Apache License Version 2.0 which is available at
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# SPDX-License-Identifier: Apache-2.0
13+
# *******************************************************************************
14+
15+
Module Template Documentation
16+
=============================
17+
18+
This documentation describes the structure, usage and configuration of the Bazel-based C++/Rust module template.
19+
20+
.. contents:: Table of Contents
21+
:depth: 2
22+
:local:
23+
24+
Overview
25+
--------
26+
27+
This repository provides a standardized setup for projects using **C++** or **Rust** and **Bazel** as a build system.
28+
It integrates best practices for build, test, CI/CD and documentation.
29+
30+
Requirements
31+
------------
32+
33+
.. stkh_req:: Example Functional Requirement
34+
:id: stkh_req__docgen_enabled
35+
:status: valid
36+
:safety: QM
37+
:reqtype: Functional
38+
:rationale: Ensure documentation builds are possible for all modules
39+
40+
41+
Project Layout
42+
--------------
43+
44+
The module template includes the following top-level structure:
45+
46+
- `src/`: Main C++/Rust sources
47+
- `tests/`: Unit and integration tests
48+
- `examples/`: Usage examples
49+
- `docs/`: Documentation using `docs-as-code`
50+
- `.github/workflows/`: CI/CD pipelines
51+
52+
Quick Start
53+
-----------
54+
55+
To build the module:
56+
57+
.. code-block:: bash
58+
59+
bazel build //src/...
60+
61+
To run tests:
62+
63+
.. code-block:: bash
64+
65+
bazel test //tests/...
66+
67+
Configuration
68+
-------------
69+
70+
The `project_config.bzl` file defines metadata used by Bazel macros.
71+
72+
Example:
73+
74+
.. code-block:: python
75+
76+
PROJECT_CONFIG = {
77+
"asil_level": "QM",
78+
"source_code": ["cpp", "rust"]
79+
}
80+
81+
This enables conditional behavior (e.g., choosing `clang-tidy` for C++ or `clippy` for Rust).

0 commit comments

Comments
 (0)