Create a link to a github resource. :param rawtext: Text being replaced with link node. :param app: Sphinx application context :param type: Link type (issues, changeset, etc.) :param slug: ID of the thing to link to :param options: Options dictionary passed to role func.
(rawtext, app, type, slug, options)
| 24 | info = getLogger(__name__).info |
| 25 | |
| 26 | def make_link_node(rawtext, app, type, slug, options): |
| 27 | """Create a link to a github resource. |
| 28 | |
| 29 | :param rawtext: Text being replaced with link node. |
| 30 | :param app: Sphinx application context |
| 31 | :param type: Link type (issues, changeset, etc.) |
| 32 | :param slug: ID of the thing to link to |
| 33 | :param options: Options dictionary passed to role func. |
| 34 | """ |
| 35 | |
| 36 | try: |
| 37 | base = app.config.github_project_url |
| 38 | if not base: |
| 39 | raise AttributeError |
| 40 | if not base.endswith('/'): |
| 41 | base += '/' |
| 42 | except AttributeError as err: |
| 43 | raise ValueError('github_project_url configuration value is not set (%s)' % str(err)) |
| 44 | |
| 45 | ref = base + type + '/' + slug + '/' |
| 46 | set_classes(options) |
| 47 | prefix = "#" |
| 48 | if type == 'pull': |
| 49 | prefix = "PR " + prefix |
| 50 | node = nodes.reference(rawtext, prefix + utils.unescape(slug), refuri=ref, |
| 51 | **options) |
| 52 | return node |
| 53 | |
| 54 | def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]): |
| 55 | """Link to a GitHub issue. |