imfreedom/gir-tools
Clone
Summary
Browse
Changes
Graph
Add a stylesheet for linting gir files
7 months ago, Gary Kramlich
6919ef9d47bf
Add a stylesheet for linting gir files
<?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>