Skip to content

Commit

Permalink
Add ability to generate materials for different versions of guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Cooper committed Aug 5, 2020
1 parent 3458772 commit 3ed0e0a
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,9 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg

#############
## Apache Ant
#############

build.properties
55 changes: 32 additions & 23 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<!-- The following properties need to be set appropriately before doing a build - they should all be overridden by the above property file, but are kept here to serve as defaults -->
<property name="outputdir" location="." description="Directory within which the output folders are created, normally &quot;../YYYY&quot; unless doing TR in which case it is &quot;../../../TR/&lt;YYYY&gt;&quot;"/>
<property name="uri.prefix" value="file:///" description="Prefix if any that must be prepended to URIs to make it resolve on the platform"/>
<property name="guidelines.version" value="22" description="Which version of WCAG is being built"/>
<property name="w3ccvs.location" location="../../../w3ccvs"/>

<property name="xslt.factory" value="net.sf.saxon.TransformerFactoryImpl" description="Class name of the XSLT transformer factory, which sets which XSLT engine to use; must be an XSLT 2.0 processor"/>
<property name="classpath.saxon" value="lib/saxon9he.jar" description="Path to Saxon jar in order to run XSLT 2.0"/>
Expand Down Expand Up @@ -96,13 +98,14 @@
</target>

<target name="guidelines" depends="init">
<mkdir dir="output/guidelines/22"/>
<copy file="guidelines/guidelines.css" todir="output/guidelines/22"/>
<copy file="guidelines/relative-luminance.xml" todir="output/guidelines/22"/>
<mkdir dir="output/guidelines/${guidelines.version}"/>
<copy file="css/base.css" todir="output/guidelines/${guidelines.version}"/>
<copy file="guidelines/guidelines.css" todir="output/guidelines/${guidelines.version}"/>
<copy file="guidelines/relative-luminance.xml" todir="output/guidelines/${guidelines.version}"/>
<exec executable="curl">
<arg value="&quot;https://labs.w3.org/spec-generator/?type=respec&amp;url=https://raw.githack.com/w3c/wcag/master/guidelines/index.html&quot;"/>
<arg value="-o"/>
<arg value="output/guidelines/22/index.html"/>
<arg value="output/guidelines/${guidelines.version}/index.html"/>
<arg value="-f"/>
<arg value="--retry"/>
<arg value="3"/>
Expand Down Expand Up @@ -175,16 +178,18 @@
<xslt in="${inputdir.techniques}/techniques.xml" out="output.html" style="xslt/generate-techniques.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="guidelines.version" expression="${guidelines.version}"/>
<param name="techniques.dir" expression="${base.techniques}"/>
<param name="associations.file" expression="${associations.file}"/>
<param name="output.dir" expression="${output.dir}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG21/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG21/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG21/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG${guidelines.version}/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG${guidelines.version}/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG${guidelines.version}/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://w3c.github.io/wcag/guidelines/" if="editors"/>
<param name="loc.understanding" expression="https://w3c.github.io/wcag/understanding/" if="editors"/>
<param name="loc.techniques" expression="https://w3c.github.io/wcag/techniques/" if="editors"/>
</xslt>
<copy file="css/base.css" todir="output/techniques/"/>
<copy file="techniques/techniques.css" todir="output/techniques/"/>
<copy file="css/slicenav.css" todir="output/techniques/"/>
<copy todir="output/techniques/">
Expand All @@ -211,9 +216,10 @@
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="base.dir" expression="${base.techniques}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG21/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG21/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG21/Techniques/" if="publication"/>
<param name="guidelines.version" expression="${guidelines.version}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG${guidelines.version}/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG${guidelines.version}/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG${guidelines.version}/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://w3c.github.io/wcag/guidelines/" if="editors"/>
<param name="loc.understanding" expression="https://w3c.github.io/wcag/understanding/" if="editors"/>
<param name="loc.techniques" expression="https://w3c.github.io/wcag/techniques/" if="editors"/>
Expand All @@ -232,13 +238,15 @@
<factory name="${xslt.factory}"/>
<param name="base.dir" expression="${base.understanding}"/>
<param name="output.dir" expression="${output.dir}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG21/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG21/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG21/Techniques/" if="publication"/>
<param name="guidelines.version" expression="${guidelines.version}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG${guidelines.version}/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG${guidelines.version}/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG${guidelines.version}/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://w3c.github.io/wcag/guidelines/" if="editors"/>
<param name="loc.understanding" expression="https://w3c.github.io/wcag/understanding/" if="editors"/>
<param name="loc.techniques" expression="https://w3c.github.io/wcag/techniques/" if="editors"/>
</xslt>
<copy file="css/base.css" todir="output/understanding/"/>
<copy file="understanding/understanding.css" todir="output/understanding/"/>
<copy file="css/slicenav.css" todir="output/understanding/"/>
<copy todir="output/understanding/img/" flatten="true">
Expand Down Expand Up @@ -267,9 +275,10 @@
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="base.dir" expression="${base.understanding}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG21/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG21/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG21/Techniques/" if="publication"/>
<param name="guidelines.version" expression="${guidelines.version}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG${guidelines.version}/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG${guidelines.version}/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG${guidelines.version}/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://w3c.github.io/wcag/guidelines/" if="editors"/>
<param name="loc.understanding" expression="https://w3c.github.io/wcag/understanding/" if="editors"/>
<param name="loc.techniques" expression="https://w3c.github.io/wcag/techniques/" if="editors"/>
Expand All @@ -278,11 +287,11 @@

<!-- Requirements -->
<target name="requirements" depends="init">
<mkdir dir="output/requirements/22"/>
<mkdir dir="output/requirements/${guidelines.version}"/>
<exec executable="curl">
<arg value="&quot;https://labs.w3.org/spec-generator/?type=respec&amp;url=https://raw.githack.com/w3c/wcag/master/requirements/22/index.html&quot;"/>
<arg value="&quot;https://labs.w3.org/spec-generator/?type=respec&amp;url=https://raw.githack.com/w3c/wcag/master/requirements/${guidelines.version}/index.html&quot;"/>
<arg value="-o"/>
<arg value="output/requirements/22/index.html"/>
<arg value="output/requirements/${guidelines.version}/index.html"/>
<arg value="-f"/>
<arg value="--retry"/>
<arg value="3"/>
Expand Down Expand Up @@ -319,18 +328,18 @@
<property name="publication" value="true"/>
<antcall target="techniques"/>
<antcall target="understanding"/>
<copy todir="../../../smartcvs/WWW/WAI/WCAG21/">
<copy todir="${w3ccvs.location}/WWW/WAI/WCAG${guidelines.version}/">
<fileset dir="output/"/>
<globmapper from="*index.html" to="*Overview.html"/>
</copy>
<copy todir="../../../smartcvs/WWW/WAI/WCAG21/">
<copy todir="${w3ccvs.location}/WWW/WAI/WCAG${guidelines.version}/">
<fileset dir="output" excludes="index.html **/index.html"/>
</copy>
<copy todir="../../../smartcvs/WWW/WAI/WCAG21/working-examples/">
<copy todir="${w3ccvs.location}/WWW/WAI/WCAG${guidelines.version}/working-examples/">
<fileset dir="working-examples/"/>
<globmapper from="*index.html" to="*Overview.html"/>
</copy>
<copy todir="../../../smartcvs/WWW/WAI/WCAG21/working-examples/">
<copy todir="${w3ccvs.location}/WWW/WAI/WCAG${guidelines.version}/working-examples/">
<fileset dir="working-examples/" excludes="index.html **/index.html"/>
</copy>
</target>
Expand Down
17 changes: 17 additions & 0 deletions css/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.wcag21, .wcag22 {
background-color: #E9FBE9;
border-left: solid .5em #52E052;
}
span.wcag21, span.wcag22 {
margin-left: .25em;
padding-left: .25em;
}
div.wcag21, div.wcag22 {
margin: 1em auto;
padding: .5em;
page-break-inside: avoid;
}
.new-version {
font-size: smaller;
font-weight: bold;
}
6 changes: 4 additions & 2 deletions script/wcag.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
var version="22";

function titleToPathFrag (title) {
return title.toLowerCase().replace(/[\s,]+/g, "-").replace(/[\(\)]/g, "");
}

function linkUnderstanding() {
var understandingBaseURI;
if (respecConfig.specStatus == "ED") understandingBaseURI = "../../understanding/";
else understandingBaseURI = "https://www.w3.org/WAI/WCAG21/Understanding/";
else understandingBaseURI = "https://www.w3.org/WAI/WCAG" + version + "/Understanding/";
document.querySelectorAll('.sc').forEach(function(node){
var heading = node.firstElementChild.textContent;
var pathFrag = titleToPathFrag(heading);
var el = document.createElement("div");
el.setAttribute("class", "doclinks");
el.innerHTML = "<a href=\"" + understandingBaseURI + pathFrag + ".html\">Understanding " + heading + "</a> <span class=\"screenreader\">|</span> <br /><a href=\"https://www.w3.org/WAI/WCAG21/quickref/#" + pathFrag + "\">How to Meet " + heading + "</a>";
el.innerHTML = "<a href=\"" + understandingBaseURI + pathFrag + ".html\">Understanding " + heading + "</a> <span class=\"screenreader\">|</span> <br /><a href=\"https://www.w3.org/WAI/WCAG" + version + "/quickref/#" + pathFrag + "\">How to Meet " + heading + "</a>";
node.insertBefore(el, node.children[1]);
})
}
Expand Down
24 changes: 24 additions & 0 deletions xslt/base.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
exclude-result-prefixes="#all"
version="2.0">

<xsl:param name="guidelines.version"/>

<xsl:param name="loc.guidelines">/guidelines/</xsl:param>
<xsl:param name="loc.understanding">/understanding/</xsl:param>
<xsl:param name="loc.techniques">/techniques/</xsl:param>
Expand Down Expand Up @@ -164,4 +166,26 @@
</xsl:choose>
</xsl:template>

<xsl:template match="html:*[starts-with(@class, 'wcag')]">
<xsl:if test="not($guidelines.version)">
<xsl:message terminate="yes">Guidelines version not provided</xsl:message>
</xsl:if>
<xsl:variable name="version" select="substring-after(@class, 'wcag')"/>
<xsl:choose>
<xsl:when test="$version &lt; $guidelines.version">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:when>
<xsl:when test="$version = $guidelines.version">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:text> </xsl:text><span class="new-version">New in WCAG <xsl:value-of select="$guidelines.version"/>: </span>
<xsl:apply-templates/>
</xsl:copy>
</xsl:when>
<xsl:when test="$version &gt; $guidelines.version"><!-- don't output --></xsl:when>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
1 change: 1 addition & 0 deletions xslt/generate-techniques.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
<meta charset="UTF-8" />
<xsl:apply-templates select="//html:title"/>
<link rel="stylesheet" type="text/css" href="https://www.w3.org/StyleSheets/TR/2016/base" />
<link rel="stylesheet" type="text/css" href="base.css" />
<link rel="stylesheet" type="text/css" href="../techniques.css" />
<link rel="stylesheet" type="text/css" href="../slicenav.css" />
</head>
Expand Down
1 change: 1 addition & 0 deletions xslt/generate-understanding.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
<meta charset="UTF-8" />
<title><xsl:apply-templates select="//html:h1"/></title>
<link rel="stylesheet" type="text/css" href="https://www.w3.org/StyleSheets/TR/2016/base" />
<link rel="stylesheet" type="text/css" href="base.css" />
<link rel="stylesheet" type="text/css" href="understanding.css" />
<link rel="stylesheet" type="text/css" href="slicenav.css" />
</head>
Expand Down

0 comments on commit 3ed0e0a

Please sign in to comment.