-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
760 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Generated sphinx docs | ||
docs/build/ | ||
docs/_build/ | ||
# Generated API docs | ||
/docs/source/api/ | ||
!/docs/source/api/index.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,48 @@ | ||
# Copyright 2023 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Generated documentation for the docs/ directory | ||
|
||
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
load(":docgen.bzl", "sphinx_stardoc") | ||
load(":docgen.bzl", "sphinx_stardocs") | ||
|
||
package( | ||
default_applicable_licenses = ["//:package_license"], | ||
default_visibility = ["//:__subpackages__"], | ||
) | ||
|
||
sphinx_stardoc( | ||
name = "truth", | ||
out = "truth.md", | ||
input = "//lib:truth.bzl", | ||
tags = ["skip-bzlmod"], | ||
deps = ["//lib:truth_bzl"], | ||
) | ||
|
||
sphinx_stardoc( | ||
name = "analysis_test", | ||
out = "analysis_test.md", | ||
input = "//lib:analysis_test.bzl", | ||
tags = ["skip-bzlmod"], | ||
deps = ["//lib:analysis_test_bzl"], | ||
) | ||
|
||
sphinx_stardoc( | ||
name = "util", | ||
out = "util.md", | ||
input = "//lib:util.bzl", | ||
tags = ["skip-bzlmod"], | ||
deps = ["//lib:util_bzl"], | ||
) | ||
|
||
extras = [ | ||
"action_subject", | ||
"bool_subject", | ||
"collection_subject", | ||
"depset_file_subject", | ||
"dict_subject", | ||
"execution_info_subject", | ||
"expect", | ||
"expect_meta", | ||
"file_subject", | ||
"instrumented_files_info_subject", | ||
"int_subject", | ||
"label_subject", | ||
"ordered", | ||
"run_environment_info_subject", | ||
"runfiles_subject", | ||
"str_subject", | ||
"target_subject", | ||
] | ||
|
||
[ | ||
sphinx_stardoc( | ||
name = name, | ||
out = name + ".md", | ||
input = "//lib/private:" + name + ".bzl", | ||
tags = ["skip-bzlmod"], | ||
deps = ["//lib/private:" + name + "_bzl"], | ||
) | ||
for name in extras | ||
] | ||
|
||
##sphinx_stardoc( | ||
## name = "target_subject", | ||
## out = "target_subject.md", | ||
## input = "//lib/private:target_subject.bzl", | ||
## tags = ["skip-bzlmod"], | ||
## deps = ["//lib/private:target_subject_bzl"], | ||
##) | ||
## | ||
##sphinx_stardoc( | ||
## name = "expect_meta", | ||
## out = "expect_meta.md", | ||
## input = "//lib/private:expect_meta.bzl", | ||
## tags = ["skip-bzlmod"], | ||
## deps = ["//lib/private:expect_meta_bzl"], | ||
##) | ||
|
||
filegroup( | ||
sphinx_stardocs( | ||
name = "docs", | ||
srcs = [ | ||
":analysis_test", | ||
":truth", | ||
":util", | ||
] + extras, | ||
) | ||
|
||
build_test( | ||
name = "docs_build_test", | ||
tags = ["skip-bzlmod"], | ||
targets = [ | ||
":truth", | ||
":util", | ||
":analysis_test", | ||
bzl_libraries = [ | ||
"//lib:analysis_test_bzl", | ||
"//lib:truth_bzl", | ||
"//lib:util_bzl", | ||
"//lib/private:action_subject_bzl", | ||
"//lib/private:bool_subject_bzl", | ||
"//lib/private:collection_subject_bzl", | ||
"//lib/private:depset_file_subject_bzl", | ||
"//lib/private:dict_subject_bzl", | ||
"//lib/private:execution_info_subject_bzl", | ||
"//lib/private:expect_bzl", | ||
"//lib/private:expect_meta_bzl", | ||
"//lib/private:file_subject_bzl", | ||
"//lib/private:instrumented_files_info_subject_bzl", | ||
"//lib/private:int_subject_bzl", | ||
"//lib/private:label_subject_bzl", | ||
"//lib/private:ordered_bzl", | ||
"//lib/private:run_environment_info_subject_bzl", | ||
"//lib/private:runfiles_subject_bzl", | ||
"//lib/private:str_subject_bzl", | ||
"//lib/private:target_subject_bzl", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,70 @@ | ||
"""Rules to help generating rules_testing docs.""" | ||
# Copyright 2023 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Rules to help generate rules_testing docs.""" | ||
|
||
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
|
||
def sphinx_stardocs(name, bzl_libraries, **kwargs): | ||
"""Generate Sphinx-friendly markdown docs using Stardoc for bzl libraries. | ||
Args: | ||
name: str, the name of the resulting file group with the generated docs. | ||
bzl_libraries: list of targets, the libraries to generate docs for. | ||
The must be in "//foo:{name}_bzl" format; the `{name}` portion | ||
will become the output file name. | ||
**kwargs: Additional kwargs to pass onto generated targets (e.g. | ||
tags) | ||
""" | ||
|
||
# Stardoc doesn't yet work with bzlmod; we can detect this by | ||
# looking for "@@" vs "@" in labels. | ||
if "@@" in str(Label("//:X")): | ||
kwargs["target_compatible_with"] = ["@platforms//:incompatible"] | ||
|
||
docs = [] | ||
for label in bzl_libraries: | ||
lib_name = Label(label).name.replace("_bzl", "") | ||
|
||
doc_rule_name = "_{}_{}".format(name, lib_name) | ||
sphinx_stardoc( | ||
name = "_{}_{}".format(name, lib_name), | ||
out = lib_name + ".md", | ||
input = label.replace("_bzl", ".bzl"), | ||
deps = [label], | ||
**kwargs | ||
) | ||
docs.append(doc_rule_name) | ||
|
||
native.filegroup( | ||
name = name, | ||
srcs = docs, | ||
**kwargs | ||
) | ||
build_test( | ||
name = name + "_build_test", | ||
targets = docs, | ||
**kwargs | ||
) | ||
|
||
def sphinx_stardoc(**kwargs): | ||
stardoc( | ||
# copybara-marker: stardoc format | ||
func_template = "func_template.vm", | ||
header_template = "header_template.vm", | ||
rule_template = "rule_template.vm", | ||
provider_template = "provider_template.vm", | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.