@@ -89,6 +89,37 @@ def _merge_sourcelinks(name, sourcelinks):
8989 tools = ["@score_docs_as_code//scripts_bazel:merge_sourcelinks" ],
9090 )
9191
92+ def _missing_requirements (deps ):
93+ """Add Python hub dependencies if they are missing."""
94+ found = []
95+ missing = []
96+ def _target_to_packagename (target ):
97+ return target .split ("/" )[- 1 ].split (":" )[0 ]
98+ all_packages = [_target_to_packagename (pkg ) for pkg in all_requirements ]
99+ def _find (pkg ):
100+ for dep in deps :
101+ dep_pkg = _target_to_packagename (dep )
102+ if dep_pkg == pkg :
103+ return True
104+ return False
105+ for pkg in all_packages :
106+ if _find (pkg ):
107+ found .append (pkg )
108+ else :
109+ missing .append (pkg )
110+ if len (missing ) == len (all_requirements ):
111+ #print("All docs-as-code dependencies are missing, adding all of them.")
112+ return all_requirements
113+ if len (missing ) == 0 :
114+ #print("All docs-as-code dependencies are already included, no need to add any.")
115+ return []
116+ if len (found ) > 0 :
117+ msg = "Some docs-as-code dependencies are in deps: " + ", " .join (found ) + \
118+ "\n ... but others are missing: " + ", " .join (missing ) + \
119+ "\n Inconsistent deps for docs(): either include all dependencies or none of them."
120+ fail (msg )
121+ fail ("This case should be unreachable?!" )
122+
92123def docs (source_dir = "docs" , data = [], deps = [], scan_code = []):
93124 """Creates all targets related to documentation.
94125
@@ -107,7 +138,8 @@ def docs(source_dir = "docs", data = [], deps = [], scan_code = []):
107138 fail ("docs() must be called from the root package. Current package: " + call_path )
108139
109140 module_deps = deps
110- deps = deps + all_requirements + [
141+ deps = deps + _missing_requirements (deps )
142+ deps = deps + [
111143 "@score_docs_as_code//src:plantuml_for_python" ,
112144 "@score_docs_as_code//src/extensions/score_sphinx_bundle:score_sphinx_bundle" ,
113145 ]
0 commit comments