MCPcopy Create free account
hub / github.com/pallets/flask / github_link

Function github_link

docs/conf.py:68–93  ·  view source on GitHub ↗
(name, rawtext, text, lineno, inliner, options=None, content=None)

Source from the content-addressed store, hash-verified

66
67
68def github_link(name, rawtext, text, lineno, inliner, options=None, content=None):
69 app = inliner.document.settings.env.app
70 release = app.config.release
71 base_url = "https://github.com/pallets/flask/tree/"
72
73 if text.endswith(">"):
74 words, text = text[:-1].rsplit("<", 1)
75 words = words.strip()
76 else:
77 words = None
78
79 if packaging.version.parse(release).is_devrelease:
80 url = f"{base_url}main/{text}"
81 else:
82 url = f"{base_url}{release}/{text}"
83
84 if words is None:
85 words = url
86
87 from docutils.nodes import reference
88 from docutils.parsers.rst.roles import set_classes
89
90 options = options or {}
91 set_classes(options)
92 node = reference(rawtext, words, refuri=url, **options)
93 return [node], []
94
95
96def setup(app):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected