Home¶
A pyrig plugin that configures a project badge.
Overview¶
pyrig-badge is a pyrig plugin that
manages a project logo SVG, a banner containing the logo inline, and Shields.io
badge data, then adds a linked banner image to the project README and this
documentation landing page.
Generated assets¶
docs/assets/logo.svgcontains the project logo. The plugin supplies the standard SVG root element and namespace, with default dimensions of200by200and a viewBox of0 0 200 200when those attributes are absent. A new file starts as an empty SVG for you to customize.docs/assets/banner.svgcontains the logo's SVG content inlined as a nested<svg>element, synced fromdocs/assets/logo.svg, so the banner renders without referencing another file. The logo is positioned within the banner's viewBox using its original dimensions, with centering offsets rounded down to integers. The banner has the same default dimensions and viewBox as the logo, and its viewBox grows to fit a larger logo.docs/assets/badge.jsoncontains the Shields.io badge configuration, including the project name, badge colors, and embedded logo markup. ItslogoSvgvalue is synced fromdocs/assets/logo.svg.
Customization¶
During pyrig sync, Pyrig enforces the following:
- In
docs/assets/logo.svganddocs/assets/banner.svg, the root element is<svg>withxmlns="http://www.w3.org/2000/svg". Missingwidth,height, andviewBoxattributes are filled with default values, but existing logo values are preserved. - In the banner's nested logo
<svg>, the logo's attributes and elements are mirrored, andwidth,height, andviewBoxmatch the logo's. Itsxandyare the banner viewBox's minimum coordinates plus half the remaining width and height, rounded down to integers; these override anyxoryset on the logo itself. The logo is drawn at its own size in the banner's viewBox units. Sync adds and updates content but never removes it, so elements or attributes deleted from the logo must also be deleted from the banner's nested<svg>. - The banner's viewBox width and height are raised to at least the logo's width
and height, so the logo is never cropped. The viewBox's minimum coordinates
and the banner's
widthandheightare kept; the viewBox scales to them. - In
docs/assets/badge.json,messageis the project name andlogoSvgis the content oflogo.svg. Missinglabeldefaults to an empty string, and missinglabelColorandcolordefault towhite; existing values are preserved.
Artwork, additional SVG attributes and elements, SVG dimensions and viewBoxes, and badge labels and colors can be customized. Inserting the logo into the banner requires the logo's dimensions to be integers without units and the banner viewBox to contain exactly four whitespace-separated integers.
Usage¶
Add the plugin as a development dependency and run pyrig sync to regenerate
the project configuration:
API Reference¶
For class- and method-level details, see the API reference, generated automatically from the source.