Skip to content

Expand sigil replacement for functions, enum values

FeRD (Frank Dana) requested to merge ferdnyc/gi-docgen:sigil-code into main

This MR contains three commits, all of which modify gidocgen/mdext.py.

  1. Create a SigilReplacement class which handles the replacement of sigil strings in the documentation, encapsulating both the pattern and replacement strings together into a single object for readability. All of the existing patterns and replacements are converted into SigilReplacement instances which are stored in a tuple, then applied in order programmatically. This is entirely a code-readability / quality-of-life change.

  2. Adjust the SigilReplacement("Function") pattern so that functions followed by punctuation will be matched and processed. Previously, this would be matched:

    Call gtk_image_new_from_icon_name() to construct.

    But this would not:

    Call gtk_image_new_from_icon_name(), the constructor.
  3. Add a SigilReplacement("Enum") to match enum values, which previously were not being replaced.

The last change can help avoid MarkDown parsing disasters like the following (from the live Gtk3 docs): image

With the code in this MR, that becomes: image

Merge request reports