Skip to content

Commit c736f37

Browse files
switch to central docs-as-code tooling (#1052)
1 parent 2cfe8f5 commit c736f37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+22
-7953
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

BUILD

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# *******************************************************************************
1313

1414
load("@score_cr_checker//:cr_checker.bzl", "copyright_checker")
15-
load("@score_dash_license_checker//:dash.bzl", "dash_license_checker")
1615
load("@score_starpls_lsp//:starpls.bzl", "setup_starpls")
1716

1817
test_suite(
@@ -44,12 +43,6 @@ exports_files([
4443
"BUILD",
4544
])
4645

47-
dash_license_checker(
48-
src = "//docs:requirements_lock",
49-
file_type = "requirements",
50-
visibility = ["//visibility:public"],
51-
)
52-
5346
setup_starpls(
5447
name = "starpls_server",
5548
visibility = ["//visibility:public"],

MODULE.bazel

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,6 @@ python.toolchain(
3434
)
3535
use_repo(python)
3636

37-
###############################################################################
38-
#
39-
# docs dependencies (Sphinx)
40-
#
41-
###############################################################################
42-
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
43-
pip.parse(
44-
hub_name = "pip_sphinx",
45-
python_version = PYTHON_VERSION,
46-
requirements_lock = "//docs:_tooling/requirements_lock.txt",
47-
)
48-
use_repo(pip, "pip_sphinx")
49-
5037
# Additional Python rules provided by aspect, e.g. an improved version of
5138
# `py_binary`. But more importantly, it provides `py_venv`.
5239
bazel_dep(name = "aspect_rules_py", version = "1.0.0")
@@ -80,26 +67,13 @@ bazel_dep(name = "aspect_rules_lint", version = "1.0.3")
8067
###############################################################################
8168
bazel_dep(name = "rules_java", version = "8.6.3")
8269

83-
###############################################################################
84-
#
85-
# HTTP Jar rule deps
86-
#
87-
###############################################################################
88-
89-
http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
90-
91-
http_jar(
92-
name = "plantuml",
93-
sha256 = "6f38f70455d08438979451c2257cd5d58647c6460094bb829bc2a12878d47331",
94-
url = "https://github.com/plantuml/plantuml/releases/download/v1.2025.0/plantuml-1.2025.0.jar",
95-
)
96-
9770
###############################################################################
9871
#
9972
# Misc. dependency
10073
#
10174
###############################################################################
102-
bazel_dep(name = "score_dash_license_checker", version = "0.1.1")
75+
76+
bazel_dep(name = "score_python_basics", version = "0.3.0")
10377

10478
###############################################################################
10579
#
@@ -114,3 +88,6 @@ bazel_dep(name = "score_cr_checker", version = "0.2.2")
11488
#
11589
###############################################################################
11690
bazel_dep(name = "score_starpls_lsp", version = "0.1.0")
91+
# Checker rule for CopyRight checks/fixs
92+
93+
bazel_dep(name = "score_docs_as_code", version = "0.1.0")

docs/BUILD

Lines changed: 10 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -11,78 +11,32 @@
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
1313

14-
load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_library", "py_venv")
15-
load("@pip_sphinx//:requirements.bzl", "all_requirements", "requirement")
1614
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
1715
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
18-
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
19-
load("@rules_python//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
20-
load("//docs:_tooling/docs.bzl", "docs")
21-
load("//tools/testing/pytest:defs.bzl", "score_py_pytest")
22-
23-
sphinx_requirements = all_requirements + [
24-
"@rules_python//python/runfiles",
25-
":plantuml_for_python",
26-
]
16+
load("@score_docs_as_code//:docs.bzl", "docs")
2717

2818
# Creates all documentation targets:
2919
# - `docs:incremental` for building docs incrementally at runtime
3020
# - `docs:live_preview` for live preview in the browser without an IDE
3121
# - `docs:ide_support` for creating python virtualenv for IDE support
3222
# - `docs:docs` for building documentation at build-time
33-
docs(source_files_to_scan_for_needs_links = [
34-
# Note: you can add filegroups, globs, or entire targets here.
35-
":score_metamodel_files",
36-
":score_source_code_linker",
37-
])
38-
39-
sphinx_build_binary(
40-
name = "sphinx_build",
41-
deps = sphinx_requirements,
42-
)
4323

44-
# These are only exported because they're passed as files to the //docs.bzl
45-
# macros, and thus must be visible to other packages. They should only be
46-
# referenced by the //docs.bzl macros.
47-
exports_files(
48-
glob(
49-
[
50-
"_tooling/**/*.py",
51-
],
52-
) + ["_tooling/requirements_lock.txt"],
53-
visibility = ["//visibility:public"],
54-
)
55-
56-
# In order to update the requirements, change the `requirements.txt` file and run:
57-
# `bazel run //docs:requirements`.
58-
# This will update the `requirements_lock.txt` file.
59-
# To upgrade all dependencies to their latest versions, run:
60-
# `bazel run //docs:requirements -- --upgrade`.
61-
compile_pip_requirements(
62-
name = "requirements",
63-
src = "_tooling/requirements.txt",
64-
requirements_txt = "_tooling/requirements_lock.txt",
65-
tags = [
66-
"manual",
24+
docs(
25+
conf_dir = "docs",
26+
docs_targets = [
27+
{
28+
"suffix": "", # local without external needs
29+
},
6730
],
68-
)
69-
70-
# Enables source_code_linker to parse all file types, not just .py
71-
filegroup(
72-
name = "score_metamodel_files",
73-
srcs = glob(
74-
["_tooling/extensions/score_metamodel/**"],
75-
exclude = ["**/__pycache__/**"],
76-
),
77-
visibility = ["//visibility:public"],
31+
source_dir = "docs",
32+
source_files_to_scan_for_needs_links = [],
7833
)
7934

8035
# Used inside //docs.bzl to enable access to the assets (css files etc.)
8136
filegroup(
82-
name = "docs_assets",
37+
name = "assets",
8338
srcs = glob([
8439
"_assets/**",
85-
"_tooling/assets/**",
8640
]),
8741
visibility = ["//visibility:public"],
8842
)
@@ -103,115 +57,3 @@ pkg_tar(
10357
name = "github-pages",
10458
srcs = [":html_files"],
10559
)
106-
107-
java_binary(
108-
name = "plantuml",
109-
jvm_flags = ["-Djava.awt.headless=true"],
110-
main_class = "net.sourceforge.plantuml.Run",
111-
runtime_deps = [
112-
"@plantuml//jar",
113-
],
114-
)
115-
116-
# This makes it possible for py_venv to depend on plantuml.
117-
# Note: py_venv can only depend on py_library.
118-
# TODO: This can be removed with the next
119-
# upgrade of `aspect_rules_py` since the py_venv rule now supports a data field
120-
py_library(
121-
name = "plantuml_for_python",
122-
srcs = ["_tooling/dummy.py"],
123-
data = [
124-
":plantuml",
125-
],
126-
)
127-
128-
filegroup(
129-
name = "test_rst_files",
130-
srcs = glob([
131-
"_tooling/extensions/score_metamodel/tests/rst/**/*.rst",
132-
"_tooling/extensions/**/*.py",
133-
"conf.py",
134-
]),
135-
visibility = ["//visibility:public"],
136-
)
137-
138-
# Dedicated metamodel target only for pytest.
139-
# It's required to define the imports for bazel pytest, so that python/pytest can
140-
# import "from score_metamodel" without issues.
141-
py_library(
142-
name = "score_metamodel",
143-
srcs = glob(["_tooling/extensions/score_metamodel/**/*.py"]),
144-
imports = ["_tooling/extensions"],
145-
visibility = ["//visibility:public"],
146-
)
147-
148-
score_py_pytest(
149-
name = "score_metamodel_test",
150-
size = "small",
151-
srcs = glob(["_tooling/extensions/score_metamodel/tests/**/*.py"]),
152-
data = [
153-
":test_rst_files",
154-
],
155-
visibility = ["//visibility:public"],
156-
deps = [
157-
":score_metamodel",
158-
],
159-
)
160-
161-
# ───────────────────────── Source code linker ────────────────────────
162-
# For more information see documentation at _tooling/extensions/score_source_code_linker/README.md
163-
py_library(
164-
name = "score_source_code_linker",
165-
srcs = glob(
166-
["_tooling/extensions/score_source_code_linker/**/*.py"],
167-
exclude = ["_tooling/extensions/score_source_code_linker/tests/*.py"],
168-
),
169-
imports = ["_tooling/extensions"],
170-
visibility = ["//visibility:public"],
171-
)
172-
173-
score_py_pytest(
174-
name = "score_source_code_linker_test",
175-
size = "small",
176-
srcs = glob(["_tooling/extensions/score_source_code_linker/tests/**/*.py"]),
177-
deps = [
178-
":score_source_code_linker",
179-
],
180-
)
181-
182-
# Needed to make the file parser executeable and findable for the source_code_linker aspect
183-
py_binary(
184-
name = "parsed_source_files_for_source_code_linker",
185-
srcs = ["_tooling/extensions/score_source_code_linker/parse_source_files.py"],
186-
visibility = ["//visibility:public"],
187-
)
188-
189-
# Running this executes the `collect_source_files.bzl` aspect.
190-
# Collects all source files from specified targets in 'deps', and makes them available for parsing for the source_code_linker
191-
192-
# Needed for Dash tool to check python dependency licenses.
193-
filegroup(
194-
name = "requirements_lock",
195-
srcs = [
196-
"_tooling/requirements_lock.txt",
197-
],
198-
visibility = ["//visibility:public"],
199-
)
200-
201-
# Dedicated metamodel target only for pytest.
202-
# It's required to define the imports for bazel pytest, so that python/pytest can
203-
# import "from header_service" without issues.
204-
py_library(
205-
name = "header_service",
206-
srcs = glob(["_tooling/extensions/score_header_service/**/*.py"]),
207-
imports = ["_tooling/extensions"],
208-
visibility = ["//visibility:public"],
209-
)
210-
211-
score_py_pytest(
212-
name = "header_service_test",
213-
size = "small",
214-
srcs = glob(["_tooling/extensions/score_header_service/test/**/*.py"]),
215-
visibility = ["//visibility:public"],
216-
deps = [":header_service"],
217-
)

0 commit comments

Comments
 (0)