Skip to content

Commit 286682f

Browse files
authored
Introduction of sphinx_toolchain (#116)
* Introduction of sphinx_toolchain This PR introduces a sphinx_toolchain. With this changes users can introduce their own custom toolchain for rules_score. * Fixed bug
1 parent 31ff8ee commit 286682f

24 files changed

Lines changed: 1158 additions & 428 deletions

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ jobs:
2525
bazel test //coverage/tests:all
2626
- name: Run rules_score tests
2727
run: |
28-
bazel test //bazel/rules/rules_score/...
28+
cd bazel/rules/rules_score/test
29+
bazel test //...

MODULE.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module(
2222
###############################################################################
2323
bazel_dep(name = "rules_python", version = "1.4.1")
2424
bazel_dep(name = "aspect_rules_py", version = "1.4.0")
25+
bazel_dep(name = "platforms", version = "1.0.0")
2526
bazel_dep(name = "aspect_rules_lint", version = "1.5.3")
2627
bazel_dep(name = "rules_shell", version = "0.5.0")
2728
bazel_dep(name = "rules_java", version = "8.15.1")
@@ -94,7 +95,6 @@ multitool.hub(
9495
)
9596
use_repo(multitool, "yamlfmt_hub")
9697

97-
bazel_dep(name = "score_docs_as_code", version = "3.0.1", dev_dependency = True)
98-
99-
# bazel_dep(name = "score_platform", version = "0.5.0")
100-
bazel_dep(name = "score_process", version = "1.3.2")
98+
register_toolchains(
99+
"//bazel/rules/rules_score:sphinx_default_toolchain",
100+
)

bazel/rules/rules_score/BUILD

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_library")
2+
load(
3+
"@score_tooling//bazel/rules/rules_score:sphinx_toolchain.bzl",
4+
"sphinx_toolchain",
5+
)
16
load(
27
"//bazel/rules/rules_score:rules_score.bzl",
38
"sphinx_module",
@@ -8,8 +13,26 @@ exports_files([
813
"templates/seooc_index.template.rst",
914
"templates/unit.template.rst",
1015
"templates/component.template.rst",
16+
"src/sphinx_wrapper.py",
17+
"src/bazel_sphinx_needs.py",
1118
])
1219

20+
sphinx_module(
21+
name = "rules_score_doc",
22+
srcs = glob(
23+
[
24+
"docs/**/*.rst",
25+
"docs/**/*.puml",
26+
],
27+
allow_empty = True,
28+
),
29+
index = "docs/index.rst",
30+
visibility = ["//visibility:public"],
31+
deps = [
32+
# "@score_process//:score_process_module",
33+
],
34+
)
35+
1336
# HTML merge tool
1437
py_binary(
1538
name = "sphinx_html_merge",
@@ -18,36 +41,52 @@ py_binary(
1841
visibility = ["//visibility:public"],
1942
)
2043

44+
py_library(
45+
name = "sphinx_module_ext",
46+
srcs = ["src/bazel_sphinx_needs.py"],
47+
imports = ["src"],
48+
visibility = ["//visibility:public"],
49+
)
50+
2151
# Sphinx build binary with all required dependencies
2252
py_binary(
23-
name = "score_build",
53+
name = "sphinx_build",
2454
srcs = ["src/sphinx_wrapper.py"],
25-
data = [],
26-
env = {
27-
"SOURCE_DIRECTORY": "",
28-
"DATA": "",
29-
"ACTION": "check",
30-
},
3155
main = "src/sphinx_wrapper.py",
3256
visibility = ["//visibility:public"],
3357
deps = [
34-
"@score_docs_as_code//src:plantuml_for_python",
35-
"@score_docs_as_code//src/extensions/score_sphinx_bundle",
58+
":sphinx_module_ext",
59+
"@pip_tooling//myst_parser",
60+
"@pip_tooling//sphinx",
61+
"@pip_tooling//sphinx_design",
62+
"@pip_tooling//sphinx_needs",
63+
"@pip_tooling//sphinx_rtd_theme",
64+
"@pip_tooling//sphinxcontrib_plantuml",
3665
],
3766
)
3867

39-
sphinx_module(
40-
name = "rules_score_doc",
41-
srcs = glob(
42-
[
43-
"docs/**/*.rst",
44-
"docs/**/*.puml",
45-
],
46-
allow_empty = True,
47-
),
48-
index = "docs/index.rst",
68+
sphinx_toolchain(
69+
name = "default_toolchain",
70+
conf_template = "@score_tooling//bazel/rules/rules_score:templates/conf.template.py",
71+
html_merge_tool = ":sphinx_html_merge",
72+
sphinx = ":sphinx_build",
73+
)
74+
75+
toolchain_type(
76+
name = "toolchain_type",
4977
visibility = ["//visibility:public"],
50-
deps = [
51-
"@score_process//:score_process_module",
78+
)
79+
80+
toolchain(
81+
name = "sphinx_default_toolchain",
82+
exec_compatible_with = [
83+
"@platforms//os:linux",
84+
"@platforms//cpu:x86_64",
85+
],
86+
target_compatible_with = [
87+
"@platforms//os:linux",
88+
"@platforms//cpu:x86_64",
5289
],
90+
toolchain = ":default_toolchain",
91+
toolchain_type = ":toolchain_type",
5392
)

0 commit comments

Comments
 (0)