Skip to content
Merged
Changes from all 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
17 changes: 4 additions & 13 deletions tools/protodoc/protodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
# http://www.fileformat.info/info/unicode/char/2063/index.htm
UNICODE_INVISIBLE_SEPARATOR = u'\u2063'

# Template for data plane API URLs.
DATA_PLANE_API_URL_FMT = 'https://github.com/envoyproxy/envoy/blob/{}/api/%s#L%d'.format(
os.environ['ENVOY_BLOB_SHA'])

# Template for formating extension descriptions.
EXTENSION_TEMPLATE = Template(
"""
Expand Down Expand Up @@ -149,7 +145,7 @@ def hide_not_implemented(comment):
return annotations.NOT_IMPLEMENTED_HIDE_ANNOTATION in comment.annotations


def github_url(type_context):
def github_url(text, type_context):
"""Obtain data plane API Github URL by path from a TypeContext.

Args:
Expand All @@ -158,10 +154,7 @@ def github_url(type_context):
Returns:
A string with a corresponding data plane API GitHub Url.
"""
if type_context.location is not None:
return DATA_PLANE_API_URL_FMT % (
type_context.source_code_info.name, type_context.location.span[0])
return ''
return f":repo:`{text} <api/{type_context.source_code_info.name}#L{type_context.location.span[0]}>`"


def format_comment_with_annotations(comment, type_name=''):
Expand Down Expand Up @@ -679,8 +672,7 @@ def visit_enum(self, enum_proto, type_context):
normal_enum_type = normalize_type_context_name(type_context.name)
anchor = format_anchor(enum_cross_ref_label(normal_enum_type))
header = format_header('-', 'Enum %s' % normal_enum_type)
_github_url = github_url(type_context)
proto_link = format_external_link('[%s proto]' % normal_enum_type, _github_url) + '\n\n'
proto_link = github_url("f[{normal_enum_type} proto]", type_context) + '\n\n'
leading_comment = type_context.leading_comment
formatted_leading_comment = format_comment_with_annotations(leading_comment, 'enum')
if hide_not_implemented(leading_comment):
Expand All @@ -695,8 +687,7 @@ def visit_message(self, msg_proto, type_context, nested_msgs, nested_enums):
normal_msg_type = normalize_type_context_name(type_context.name)
anchor = format_anchor(message_cross_ref_label(normal_msg_type))
header = format_header('-', normal_msg_type)
_github_url = github_url(type_context)
proto_link = format_external_link('[%s proto]' % normal_msg_type, _github_url) + '\n\n'
proto_link = github_url(f"[{normal_msg_type} proto]", type_context) + '\n\n'
leading_comment = type_context.leading_comment
formatted_leading_comment = format_comment_with_annotations(leading_comment, 'message')
if hide_not_implemented(leading_comment):
Expand Down