-
Notifications
You must be signed in to change notification settings - Fork 2
/
BUILD.bazel
115 lines (99 loc) · 2.42 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
load(
"//bazeldoc:defs.bzl",
"doc_for_provs",
"write_file_list",
"write_header",
doc_providers = "providers",
)
load("//bzlformat:defs.bzl", "bzlformat_pkg")
bzlformat_pkg(name = "bzlformat")
filegroup(
name = "doc_files",
srcs = glob(["*.md"]) + [
# A doc file has a reference to this file.
"BUILD.bazel",
],
visibility = ["//:markdown_test_visibility"],
)
# Lovingly inspired by
# https://github.com/bazelbuild/rules_swift/blob/021c11b1d578ffba547140eb24854cdfe74c794f/doc/BUILD.bazel#L3
# MARK: - Documentation Declarations
_API_SRCS = [
"doc_utilities",
"providers",
]
_STARDOC_INPUT = "//bazeldoc:defs.bzl"
_DOC_DEPS = [
"//bazeldoc:defs",
]
_API_DOC_PROVIDERS = [
doc_providers.create(
name = name,
stardoc_input = _STARDOC_INPUT,
symbols = [name],
deps = _DOC_DEPS,
)
for name in _API_SRCS
]
_BUILD_RULES_PROV = doc_providers.create(
name = "build_rules_overview",
stardoc_input = _STARDOC_INPUT,
symbols = [
"doc_for_provs",
"stardoc_for_prov",
"stardoc_for_provs",
"write_doc",
"write_file_list",
"write_header",
],
deps = _DOC_DEPS,
)
_ALL_DOC_PROVIDERS = [
_BUILD_RULES_PROV,
doc_providers.create(
name = "api",
is_stardoc = False,
stardoc_input = _STARDOC_INPUT,
deps = _DOC_DEPS,
),
] + _API_DOC_PROVIDERS
# MARK: - Special Case api.md
write_file_list(
name = "api_doc",
out = "api.md_",
doc_provs = _API_DOC_PROVIDERS,
header_content = [
"# Documentation API",
"",
"The APIs described below are used by ",
"[the build rules](build_rules_overview.md) to facilitate the ",
"generation of the Starlark documentation.",
"",
],
)
# MARK: - Headers
write_header(
name = "build_rules_overview_header",
header_content = [
"# Build Rules",
"",
"The macros described below are used to generate, test and copy ",
"Starlark documentation.",
],
symbols = _BUILD_RULES_PROV.symbols,
)
# Write the API headers
[
write_header(
name = doc_prov.header_label,
out = doc_prov.header_basename,
header_content = [
"# `{name}` API".format(name = doc_prov.name),
],
)
for doc_prov in _API_DOC_PROVIDERS
if doc_prov.is_stardoc
]
doc_for_provs(
doc_provs = _ALL_DOC_PROVIDERS,
)