Skip to content

Commit 29c622c

Browse files
Initial cleanup (#5)
* Renamed vars for readability * small improvements and cleanup * Moving of BUILD files * Moving string_links option * Formatting Preparation commit to move all py_libraries to their own BUILD files. This solution at the moment is WIP as the pre-fix needed is unacceptable. But this will serve as a base to be able to test if further changes work Moved BUILD files to separate folders for better Separation Cleaned up some smaller stuff Conf.py is cleaner again
1 parent 4e8423e commit 29c622c

20 files changed

Lines changed: 321 additions & 177 deletions

File tree

docs.bzl

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ load("@pip_process//:requirements.bzl", "all_requirements", "requirement")
4242
load("@rules_python//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
4343
load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
4444
load("@score_python_basics//:defs.bzl", "score_virtualenv")
45-
load("//src/extensions:score_source_code_linker/collect_source_files.bzl", "parse_source_files_for_needs_links")
45+
load("//src/extensions/score_source_code_linker:collect_source_files.bzl", "parse_source_files_for_needs_links")
4646

4747
sphinx_requirements = all_requirements + [
4848
"//src:plantuml_for_python",
49-
"//src/extensions:score_extensions",
49+
"//src/extensions:score_plantuml",
50+
"//src/extensions/score_draw_uml_funcs:score_draw_uml_funcs",
51+
"//src/extensions/score_header_service:score_header_service",
52+
"//src/extensions/score_layout:score_layout",
53+
"//src/extensions/score_metamodel:score_metamodel",
54+
"//src/extensions/score_source_code_linker:score_source_code_linker",
5055
]
5156

5257
def docs(source_files_to_scan_for_needs_links = None, source_dir = "docs", conf_dir = "docs", build_dir_for_incremental = "_build", docs_targets = []):
@@ -56,6 +61,11 @@ def docs(source_files_to_scan_for_needs_links = None, source_dir = "docs", conf_
5661
Current restrictions:
5762
* only callable from 'docs/BUILD'
5863
"""
64+
sphinx_build_binary(
65+
name = "sphinx_build",
66+
visibility = ["//visibility:public"],
67+
deps = sphinx_requirements,
68+
)
5969

6070
# Parse source files for needs links
6171
# This needs to be created to generate a target, otherwise it won't execute as dependency for other macros
@@ -64,7 +74,8 @@ def docs(source_files_to_scan_for_needs_links = None, source_dir = "docs", conf_
6474
srcs_and_deps = source_files_to_scan_for_needs_links if source_files_to_scan_for_needs_links else [],
6575
)
6676

67-
# TODO: Explain what this does / how it works?
77+
# We are iterating over all provided 'targets' in order to allow for automatic generation of them without
78+
# needing to modify the underlying 'docs.bzl' file.
6879
for target in docs_targets:
6980
suffix = "_" + target["suffix"] if target["suffix"] else ""
7081
external_needs_deps = target.get("target", [])
@@ -105,12 +116,12 @@ def _incremental(incremental_name = "incremental", live_name = "live_preview", s
105116
extra_dependencies: Additional dependencies besides the centrally maintained "sphinx_requirements".
106117
"""
107118

108-
dependencies = sphinx_requirements + extra_dependencies
119+
dependencies = sphinx_requirements + extra_dependencies + ["@rules_python//python/runfiles"]
109120
py_binary(
110121
name = incremental_name,
111122
srcs = ["//src:incremental.py"],
112123
deps = dependencies,
113-
data = [":score_source_code_parser"] + external_needs_deps,
124+
data = [":score_source_code_parser"] + dependencies,
114125
env = {
115126
"SOURCE_DIRECTORY": source_dir,
116127
"CONF_DIRECTORY": conf_dir,
@@ -144,7 +155,6 @@ def _ide_support():
144155
def _docs(name = "docs", format = "html", external_needs_deps = list(), external_needs_def = dict()):
145156
ext_needs_arg = "--define=external_needs_source=" + json.encode(external_needs_def)
146157

147-
#fail(ext_needs_arg)
148158
sphinx_docs(
149159
name = name,
150160
srcs = native.glob([
@@ -157,7 +167,6 @@ def _docs(name = "docs", format = "html", external_needs_deps = list(), external
157167
"**/*.need",
158168
# Include the docs src itself
159169
# Note: we don't use py_library here to make it as close as possible to docs:incremental.
160-
"**/*.py",
161170
"**/*.yaml",
162171
"**/*.json",
163172
"**/*.csv",
@@ -170,7 +179,7 @@ def _docs(name = "docs", format = "html", external_needs_deps = list(), external
170179
formats = [
171180
format,
172181
],
173-
sphinx = "//src:sphinx_build",
182+
sphinx = ":sphinx_build",
174183
tags = [
175184
"manual",
176185
],

process-docs/BUILD

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,49 +25,38 @@ docs(
2525
{
2626
"suffix": "", # local without external needs
2727
},
28-
29-
# ╭───────────────────────────────────────╮
30-
# │ This is commented out until local │
31-
# │ multi-repo testing is implemented │
32-
# ╰───────────────────────────────────────╯
33-
34-
# {
35-
# "suffix": "release", # The version imported from MODULE.bazel
36-
# "target": ["@score_platform//docs:docs"],
37-
# "external_needs_info": [
38-
# {
39-
# "base_url": "https://eclipse-score.github.io/score/pr-980/",
40-
# "json_path": "/score_platform~/docs/docs/_build/html/needs.json",
41-
# "version": "0.1",
42-
# },
43-
# ],
44-
# },
45-
# {
46-
# "suffix": "latest", # latest main branch documentation build
47-
# "external_needs_info": [
48-
# {
49-
# "base_url": "https://eclipse-score.github.io/score/main/",
50-
# "json_url": "https://maximiliansoerenpollak.github.io/score/needs.json",
51-
# "version": "0.1",
52-
# },
53-
# ],
54-
# },
5528
],
5629
source_dir = "process-docs",
5730
source_files_to_scan_for_needs_links = [
5831
# Note: you can add filegroups, globs, or entire targets here.
59-
"//src/extensions:score_extensions",
60-
":score_extensions",
61-
":score_source_code_linker",
32+
"//src:score_extension_files",
33+
"//src:plantuml_for_python",
6234
],
6335
)
6436

65-
py_library(
66-
name = "score_source_code_linker",
67-
srcs = glob(
68-
["src/extensions/score_source_code_linker/**/*.py"],
69-
exclude = ["src/extensions/score_source_code_linker/tests/*.py"],
70-
),
71-
imports = ["src/extensions"],
72-
visibility = ["//visibility:public"],
73-
)
37+
# ╭───────────────────────────────────────╮
38+
# │ This is commented out until local │
39+
# │ multi-repo testing is implemented │
40+
# ╰───────────────────────────────────────╯
41+
42+
# {
43+
# "suffix": "release", # The version imported from MODULE.bazel
44+
# "target": ["@score_platform//docs:docs"],
45+
# "external_needs_info": [
46+
# {
47+
# "base_url": "https://eclipse-score.github.io/score/pr-980/",
48+
# "json_path": "/score_platform~/docs/docs/_build/html/needs.json",
49+
# "version": "0.1",
50+
# },
51+
# ],
52+
# },
53+
# {
54+
# "suffix": "latest", # latest main branch documentation build
55+
# "external_needs_info": [
56+
# {
57+
# "base_url": "https://eclipse-score.github.io/score/main/",
58+
# "json_url": "https://maximiliansoerenpollak.github.io/score/needs.json",
59+
# "version": "0.1",
60+
# },
61+
# ],
62+
# },

process-docs/conf.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
logger = logging.getLogger("process-docs")
3333
logger.debug("Loading docs-as-code conf.py")
3434

35+
3536
extensions = [
3637
"sphinx_design",
3738
"sphinx_needs",
@@ -42,6 +43,7 @@
4243
"score_source_code_linker",
4344
"score_layout",
4445
]
46+
4547
logger.debug("After loading extensions")
4648

4749
exclude_patterns = [
@@ -58,19 +60,6 @@
5860
# Enable numref
5961
numfig = True
6062

61-
62-
# -- sphinx-needs configuration --------------------------------------------
63-
# Setting the needs layouts
64-
needs_global_options = {"collapse": True}
65-
needs_string_links = {
66-
"source_code_linker": {
67-
"regex": r"(?P<value>[^,]+)",
68-
"link_url": "{{value}}",
69-
"link_name": "Source Code Link",
70-
"options": ["source_code_link"],
71-
},
72-
}
73-
7463
# TODO: Fixing this in all builds
7564
html_static_path = ["../src/assets"]
7665

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,19 @@
33
[tool.pyright]
44
extends = "bazel-bin/process-docs/ide_support.runfiles/score_python_basics~/pyproject.toml"
55

6+
exclude = [
7+
"**/__pycache__",
8+
"**/.*",
9+
"**/bazel-*",
10+
"venv/**",
11+
]
12+
613
[tool.ruff]
714
extend = "bazel-bin/process-docs/ide_support.runfiles/score_python_basics~/pyproject.toml"
15+
16+
extend-exclude = [
17+
"**/__pycache__",
18+
"/.*",
19+
"bazel-*",
20+
"venv/**",
21+
]

src/BUILD

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,15 @@ load("@rules_python//python:pip.bzl", "compile_pip_requirements")
2020
load("@rules_python//sphinxdocs:sphinx.bzl", "sphinx_build_binary")
2121
load("@score_dash_license_checker//:dash.bzl", "dash_license_checker")
2222

23-
sphinx_requirements = all_requirements + [
24-
":plantuml_for_python",
25-
"//src/extensions:score_extensions",
26-
]
27-
28-
sphinx_build_binary(
29-
name = "sphinx_build",
30-
visibility = ["//visibility:public"],
31-
deps = sphinx_requirements,
32-
)
33-
3423
# These are only exported because they're passed as files to the //docs.bzl
3524
# macros, and thus must be visible to other packages. They should only be
3625
# referenced by the //docs.bzl macros.
26+
3727
exports_files(
3828
[
3929
"requirements.txt",
4030
"incremental.py",
31+
"dummy.py",
4132
],
4233
visibility = ["//visibility:public"],
4334
)
@@ -98,6 +89,19 @@ py_library(
9889
visibility = ["//visibility:public"],
9990
)
10091

92+
filegroup(
93+
name = "score_extension_files",
94+
srcs = glob(
95+
["*/**"],
96+
exclude = [
97+
"**/test/**",
98+
"**/tests/**",
99+
"**/__pycache__/**",
100+
],
101+
),
102+
visibility = ["//visibility:public"],
103+
)
104+
101105
# Running this executes the `collect_source_files.bzl` aspect.
102106
# Collects all source files from specified targets in 'deps', and makes them available for parsing for the source_code_linker
103107

src/extensions/BUILD

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,74 +15,15 @@ load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_library")
1515
load("@pip_process//:requirements.bzl", "all_requirements")
1616
load("@score_python_basics//:defs.bzl", "score_py_pytest", "score_virtualenv")
1717

18-
score_virtualenv(
19-
name = "process_venv",
20-
reqs = all_requirements,
21-
venv_name = ".venv_process",
22-
)
23-
24-
py_library(
25-
name = "score_extensions",
26-
srcs = glob(
27-
["**/*.py"],
28-
exclude = ["**/tests/**/*"],
29-
),
30-
data = glob([
31-
"score_layout/assets/**",
32-
"score_metamodel/*.yaml", # Needed to remove 'resolving of symlink' in score_metamodel.__init__
33-
]),
34-
imports = ["."],
35-
visibility = ["//visibility:public"],
36-
deps = [
37-
"@rules_python//python/runfiles",
38-
],
39-
)
18+
# TODO: This probably can be deleted
19+
# score_virtualenv(
20+
# name = "process_venv",
21+
# reqs = all_requirements,
22+
# venv_name = ".venv_process",
23+
# )
4024

41-
# Dedicated metamodel target only for pytest.
42-
# It's required to define the imports for bazel pytest, so that python/pytest can
43-
# import "from score_metamodel" without issues.
4425
py_library(
45-
name = "score_metamodel",
46-
srcs = glob(
47-
["score_metamodel/**/*.py"],
48-
exclude = ["**/tests/**/*"],
49-
),
50-
imports = ["extensions"],
51-
visibility = ["//visibility:public"],
52-
)
53-
54-
score_py_pytest(
55-
name = "score_metamodel_test",
56-
size = "small",
57-
srcs = glob(["score_metamodel/tests/**/*.py"]),
58-
visibility = ["//visibility:public"],
59-
deps = [":score_metamodel"] + all_requirements,
60-
)
61-
62-
# ───────────────────────── Source code linker ────────────────────────
63-
# For more information see documentation at score_source_code_linker/README.md
64-
py_library(
65-
name = "score_source_code_linker",
66-
srcs = glob(
67-
["score_source_code_linker/**/*.py"],
68-
exclude = ["score_source_code_linker/tests/*.py"],
69-
),
70-
imports = ["."],
71-
visibility = ["//visibility:public"],
72-
)
73-
74-
score_py_pytest(
75-
name = "score_source_code_linker_test",
76-
size = "small",
77-
srcs = glob(["score_source_code_linker/tests/**/*.py"]),
78-
deps = [
79-
":score_source_code_linker",
80-
] + all_requirements,
81-
)
82-
83-
# Needed to make the file parser executeable and findable for the source_code_linker aspect
84-
py_binary(
85-
name = "parsed_source_files_for_source_code_linker",
86-
srcs = ["score_source_code_linker/parse_source_files.py"],
26+
name = "score_plantuml",
27+
srcs = ["score_plantuml.py"],
8728
visibility = ["//visibility:public"],
8829
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 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+
load("@aspect_rules_py//py:defs.bzl", "py_library")
14+
load("@pip_process//:requirements.bzl", "all_requirements")
15+
16+
py_library(
17+
name = "score_draw_uml_funcs",
18+
srcs = glob(
19+
["*.py"],
20+
),
21+
imports = ["."],
22+
visibility = ["//visibility:public"],
23+
# TODO: Figure out if all requirements are needed or if we can break it down a bit
24+
deps = all_requirements,
25+
)

0 commit comments

Comments
 (0)