Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add cncf/xds protos #20277

Merged
merged 23 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,21 @@ proto_library(
],
)

proto_library(
name = "cncf_protos",
visibility = ["//visibility:public"],
deps = [
"@com_github_cncf_udpa//xds/core/v3:pkg",
"@com_github_cncf_udpa//xds/type/matcher/v3:pkg",
"@com_github_cncf_udpa//xds/type/v3:pkg",
],
)

proto_library(
name = "all_protos",
visibility = ["//visibility:public"],
deps = [
":cncf_protos",
":v2_protos",
":v3_protos",
],
Expand Down
21 changes: 21 additions & 0 deletions docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ genquery(
scope = ["@envoy_api//:v3_protos"],
)

genquery(
name = "cncf_proto_srcs",
expression = "labels(srcs, labels(deps, @envoy_api//:cncf_protos))",
scope = ["@envoy_api//:cncf_protos"],
)

genrule(
name = "empty_protos_rst",
srcs = [":empty_extensions.json"],
Expand All @@ -130,6 +136,20 @@ genrule(
tools = ["//tools/docs:generate_api_rst"],
)

genrule(
name = "cncf_rst",
srcs = [
"//tools/protodoc:cncf_protodoc",
":cncf_proto_srcs",
],
outs = ["cncf_rst.tar"],
cmd = """
$(location //tools/docs:generate_api_rst) \\
$(location cncf_proto_srcs) $(locations //tools/protodoc:cncf_protodoc) $@
""",
tools = ["//tools/docs:generate_api_rst"],
)

pkg_files(
name = "sphinx_base",
srcs = glob(
Expand Down Expand Up @@ -177,6 +197,7 @@ pkg_tar(
extension = "tar",
deps = [
":api_rst",
":cncf_rst",
":empty_protos_rst",
":extensions_security_rst",
":external_deps_rst",
Expand Down
15 changes: 15 additions & 0 deletions docs/root/api-v3/common_messages/common_messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,18 @@ Common messages
../extensions/matching/input_matchers/ip/v3/ip.proto
../extensions/matching/common_inputs/environment_variable/v3/input.proto
../extensions/matching/common_inputs/network/v3/network_inputs.proto
../../cncf/type/v3/range.proto
../../cncf/type/v3/typed_struct.proto
../../cncf/type/matcher/v3/ip.proto
../../cncf/type/matcher/v3/matcher.proto
../../cncf/type/matcher/v3/range.proto
../../cncf/type/matcher/v3/regex.proto
../../cncf/type/matcher/v3/string.proto
../../cncf/core/v3/authority.proto
../../cncf/core/v3/cidr.proto
../../cncf/core/v3/collection_entry.proto
../../cncf/core/v3/context_params.proto
../../cncf/core/v3/extension.proto
../../cncf/core/v3/resource.proto
../../cncf/core/v3/resource_locator.proto
../../cncf/core/v3/resource_name.proto
3 changes: 2 additions & 1 deletion tools/api_proto_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def plugin(output_descriptors):
f = response.file.add()
f.name = file_proto.name + od.output_suffix
# Don't run API proto plugins on things like WKT types etc.
if not file_proto.package.startswith('envoy.'):
if (not file_proto.package.startswith('envoy.') and
kyessenov marked this conversation as resolved.
Show resolved Hide resolved
not file_proto.package.startswith('xds.')):
kyessenov marked this conversation as resolved.
Show resolved Hide resolved
continue
if request.HasField("parameter") and od.want_params:
params = dict(param.split('=') for param in request.parameter.split(','))
Expand Down
6 changes: 5 additions & 1 deletion tools/docs/generate_api_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,21 @@ def main():
]

for rst_file_path in envoy_api_rst_files:
root = "api-v3"
canonical = include_package(envoy_api_protos, rst_file_path, "envoy/")
if canonical is None:
canonical = include_package(envoy_api_protos, rst_file_path, "contrib/envoy/")
if canonical is None:
canonical = include_package(envoy_api_protos, rst_file_path, "xds/")
root = "cncf"
if canonical is None:
continue

# Skip copying empty files.
if os.path.getsize(rst_file_path) == 0:
continue

target = os.path.join("rst-out/api-v3", canonical)
target = os.path.join("rst-out", root, canonical)
if not os.path.exists(os.path.dirname(target)):
os.makedirs(os.path.dirname(target))
shutil.copy(rst_file_path, target)
Expand Down
5 changes: 5 additions & 0 deletions tools/protodoc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ protodoc_rule(
name = "api_v3_protodoc",
deps = ["@envoy_api//:v3_protos"],
)

protodoc_rule(
name = "cncf_protodoc",
deps = ["@envoy_api//:cncf_protos"],
)
3 changes: 2 additions & 1 deletion tools/protodoc/protodoc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def _protodoc_rule_impl(ctx):
depset([
x
for x in ctx.attr.deps[0][OutputGroupInfo].rst.to_list()
if x.short_path.startswith("../envoy_api")
if x.short_path.startswith("../envoy_api") or
kyessenov marked this conversation as resolved.
Show resolved Hide resolved
x.short_path.startswith("../com_github_cncf_udpa")
]),
],
),
Expand Down
5 changes: 4 additions & 1 deletion tools/protodoc/protodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
# Namespace prefix for RPCs.
RPC_NAMESPACE_PREFIX = '.google.rpc.'

# Namespace prefix for cncf/xds top-level APIs.
CNCF_PREFIX = '.xds.'

# http://www.fileformat.info/info/unicode/char/2063/index.htm
UNICODE_INVISIBLE_SEPARATOR = u'\u2063'

Expand Down Expand Up @@ -429,7 +432,7 @@ def format_field_type(type_context, field):
Return: RST formatted field type.
"""
if field.type_name.startswith(ENVOY_API_NAMESPACE_PREFIX) or field.type_name.startswith(
ENVOY_PREFIX):
ENVOY_PREFIX) or field.type_name.startswith(CNCF_PREFIX):
kyessenov marked this conversation as resolved.
Show resolved Hide resolved
type_name = normalize_field_type_name(field.type_name)
if field.type == field.TYPE_MESSAGE:
if type_context.map_typenames and type_name_from_fqn(
Expand Down