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" )
1614load ("@rules_pkg//pkg:mappings.bzl" , "pkg_files" )
1715load ("@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.)
8136filegroup (
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