File: newcontrib_substitutions.py

package info (click to toggle)
python-mne 1.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 131,492 kB
  • sloc: python: 213,302; javascript: 12,910; sh: 447; makefile: 144
file content (27 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download
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
# Authors: The MNE-Python contributors.
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

from docutils.nodes import reference, strong, target


def newcontrib_role(name, rawtext, text, lineno, inliner, options={}, content=[]):  # noqa: B006
    """Create a role to highlight new contributors in changelog entries."""
    newcontrib = f"new contributor {text}"
    alias_text = f" <{text}_>"
    rawtext = f"`{newcontrib}{alias_text}`_"
    refname = text.lower()
    strong_node = strong(rawtext, newcontrib)
    target_node = target(alias_text, refname=refname, names=[newcontrib])
    target_node.indirect_reference_name = text
    options.update(refname=refname, name=newcontrib)
    ref_node = reference("", "", strong_node, **options)
    ref_node[0].rawsource = rawtext
    inliner.document.note_indirect_target(target_node)
    inliner.document.note_refname(ref_node)
    return [ref_node, target_node], []


def setup(app):
    app.add_role("newcontrib", newcontrib_role)
    return