@@ -58,6 +58,37 @@ sphinx_requirements = all_requirements + [
5858 "@score_docs_as_code//src/extensions/score_source_code_linker:score_source_code_linker" ,
5959]
6060
61+ def _set_github_settings (ctx ):
62+ """Sets GitHub settings for documentation.
63+
64+ This function creates a text file containing GitHub user and repo information,
65+ either from Bazel command line variables or default values. The file is used
66+ by Sphinx extensions to configure documentation settings.
67+ Usage example:
68+ bazel build //docs:github_pages__release --define github_user=eclipse-score --define github_repo=score
69+
70+ Args:
71+ ctx: bazel rule context.
72+
73+ Returns:
74+ A list containing DefaultInfo with runfiles for the settings file.
75+ """
76+
77+ github_user = ctx .var .get ("github_user" ) or "eclipse-score"
78+ github_repo = ctx .var .get ("github_repo" ) or "score"
79+
80+ txt = ctx .actions .declare_file ("github_settings.txt" )
81+ ctx .actions .write (output = txt , content = github_user + "," + github_repo )
82+
83+ return [
84+ DefaultInfo (runfiles = ctx .runfiles (files = [txt ])),
85+ ]
86+
87+ github_settings = rule (
88+ implementation = _set_github_settings ,
89+ attrs = {},
90+ )
91+
6192def docs (source_files_to_scan_for_needs_links = None , source_dir = "docs" , conf_dir = "docs" , build_dir_for_incremental = "_build" , docs_targets = []):
6293 """
6394 Creates all targets related to documentation.
@@ -73,6 +104,10 @@ def docs(source_files_to_scan_for_needs_links = None, source_dir = "docs", conf_
73104 srcs_and_deps = source_files_to_scan_for_needs_links if source_files_to_scan_for_needs_links else [],
74105 )
75106
107+ github_settings (
108+ name = "github_settings" ,
109+ )
110+
76111 # We are iterating over all provided 'targets' in order to allow for automatic generation of them without
77112 # needing to modify the underlying 'docs.bzl' file.
78113 for target in docs_targets :
@@ -83,7 +118,7 @@ def docs(source_files_to_scan_for_needs_links = None, source_dir = "docs", conf_
83118 sphinx_build_binary (
84119 name = "sphinx_build" + suffix ,
85120 visibility = ["//visibility:public" ],
86- data = ["@score_docs_as_code//src:docs_assets" , "@score_docs_as_code//src:score_extension_files" ] + external_needs_deps ,
121+ data = ["@score_docs_as_code//src:docs_assets" , "@score_docs_as_code//src:score_extension_files" ] + external_needs_deps + [ ":github_settings" ] ,
87122 deps = sphinx_requirements ,
88123 )
89124 _incremental (
0 commit comments