grim/gir-tools
Clone
Summary
Browse
Changes
Graph
Add a stylesheet for linting gir files
6 months ago, Gary Kramlich
6919ef9d47bf
Parents
79a1dd78243a
Children
ed9383c0fbbb
Add a stylesheet for linting gir files
1 files changed, 135 insertions(+), 0 deletions(-)
+135
-0
girlint.xsl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/girlint.xsl Wed Oct 25 03:39:14 2023 -0500
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gir="http://www.gtk.org/introspection/core/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0"
+ version="1.0"
+>
+ <xsl:output method="text"/>
+ <xsl:strip-space elements="*"/>
+
+ <xsl:variable name="newline" select="' '"/>
+ <xsl:variable name="tab" select="'	'"/>
+
+ <xsl:variable name="newline-tab">
+ <xsl:value-of select="$newline"/>
+ <xsl:value-of select="$tab"/>
+ </xsl:variable>
+
+ <!-- ignore all the cdata in doc tags -->
+ <xsl:template match="gir:doc"/>
+
+ <xsl:template match="gir:property">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('property ', ../@name, ':', @name, ' missing version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(@doc)">
+ <xsl:value-of select="concat('property ', ../@name, ':', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gir:method">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('method ', ../@name, '.', @name, ' mising version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('method ', ../@name, '.', @name, ' mising documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gir:virtual-method">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('virtual method ', ../@name, '.', @name, ' mising version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('virtual method ', ../@name, '.', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gir:function">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('function ', @name, ' mising version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('function ', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gir:constructor">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('constructor ', ../@name, '.', @name, ' mising version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('constructor ', ../@name, '.', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gir:namespace/gir:callback">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('callback ', @name, ' mising version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('callback ', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glib:signal">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('signal ', ../@name, ':', @name, ' missing version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('signal ', ../@name, ':', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gir:class">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('class ', @name, ' missing version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('class ', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="gir:enumeration">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('enumeration ', @name, ' missing version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('enumeration ', @name, ':', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gir:bitfield">
+ <xsl:if test="not(@version)">
+ <xsl:value-of select="concat('bitfield ', @name, ' missing version', $newline)"/>
+ </xsl:if>
+
+ <xsl:if test="not(gir:doc)">
+ <xsl:value-of select="concat('bitfield ', @name, ':', @name, ' missing documentation', $newline)"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="gir:namespace">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="gir:repository">
+ <xsl:apply-templates select="gir:namespace"/>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <xsl:apply-templates select="gir:repository"/>
+ </xsl:template>
+</xsl:stylesheet>