arrange things for doc.entrouvert.org

This commit is contained in:
Frédéric Péters 2012-04-29 14:54:53 +02:00
parent fceb5f9486
commit b662757aef
5 changed files with 1509 additions and 170 deletions

69
data/eo-overlay.xml Normal file
View File

@ -0,0 +1,69 @@
<?xml version="1.0"?>
<overlay>
<subsections>
<subindexes channel="devel">
<subindex id="guides" weight="1">
<sections>overview gdp-documentation tutorials faqs devel-guides</sections>
<title>Guides</title>
<abstract>
The guides provide the common practices used in code and interface
design within the GNOME platform as well as detailed knowledge about
some applications and components.
</abstract>
</subindex>
<subindex id="references" weight="0.8">
<sections>api-base api api-desktop-plugins api-bindings standards</sections>
<title>References</title>
<abstract>
The references contain the Application Programming Interface, list of
functions, classes and methods of the GNOME platform libraries and
the standards used within the GNOME platform.
</abstract>
</subindex>
<subindex id="tools" weight="0.5">
<sections>ApplicationsProgramming</sections>
<title>Development Tools</title>
<abstract>
The GNOME developer suite is a set of tools to ease the life of
developers; it features a graphical interface builder, an
integrated help system for API reference and more.
</abstract>
</subindex>
<subindex id="gnome-devel" weight="0.3">
<sections>devel-resource</sections>
<title>GNOME Development</title>
<abstract>
Various links to learn more about GNOME development and how to get
involved.
</abstract>
</subindex>
</subindexes>
<!-- devel channel -->
<subsection channel="devel" id="overview" weight="1"/>
<subsection channel="devel" id="devel-guides" weight="0.9"/>
<subsection channel="devel" id="tutorials" weight="0.8"/>
<subsection channel="devel" id="faqs" weight="0.7"/>
<subsection channel="devel" id="api-base" weight="0.8"/>
<subsection channel="devel" id="api" weight="0.75"/>
<!-- users channel -->
<subsection channel="users" id="index" weight="1.0"/>
<!-- admin channel -->
<subsection channel="admin" id="guides" weight="1.0"/>
</subsections>
<documents>
<document doc_module="lasso" channel="devel" weight="0.95">
<category>api-base</category>
<subsection>api-core</subsection>
<abstract>
Lasso bla bla bla
</abstract>
</document>
</documents>
</overlay>

167
data/skin/eo.css Normal file
View File

@ -0,0 +1,167 @@
body {
width: 900px;
margin: auto;
text-align: left;
}
dl.doc-index dt a {
text-decoration: none;
font-size: 120%;
color: #505053;
font-family: MuseoSlab, sans-serif;
}
dl.doc-index dt .module-more a {
font-size: 100%;
font-family: sans-serif;
}
/* code listings */
.listing_code .programlisting .cbracket { color: #a40000; } /* tango: scarlet red 3 */
.listing_code .programlisting .comment { color: #a1a39d; } /* tango: aluminium 4 */
.listing_code .programlisting .function { color: #000000; font-weight: bold; }
.listing_code .programlisting .function a { color: #11326b; font-weight: bold; } /* tango: sky blue 4 */
.listing_code .programlisting .keyword { color: #4e9a06; } /* tango: chameleon 3 */
.listing_code .programlisting .linenum { color: #babdb6; } /* tango: aluminium 3 */
.listing_code .programlisting .normal { color: #000000; }
.listing_code .programlisting .number { color: #75507b; } /* tango: plum 2 */
.listing_code .programlisting .preproc { color: #204a87; } /* tango: sky blue 3 */
.listing_code .programlisting .string { color: #c17d11; } /* tango: chocolate 2 */
.listing_code .programlisting .type { color: #000000; }
.listing_code .programlisting .type a { color: #11326b; } /* tango: sky blue 4 */
.listing_code .programlisting .symbol { color: #ce5c00; } /* tango: orange 3 */
.listing_frame {
/* tango:sky blue 1 */
border: solid 1px #729fcf;
padding: 0px;
}
.listing_lines, .listing_code {
margin-top: 0px;
margin-bottom: 0px;
padding: 0.5em;
}
.listing_lines {
/* tango:sky blue 0.5 */
background: #a6c5e3;
/* tango:aluminium 6 */
color: #2e3436;
}
.listing_code {
/* tango:sky blue 0 */
background: #e6f3ff;
}
.listing_code .programlisting {
/* override from previous */
border: none 0px;
padding: 0px;
}
.listing_lines pre, .listing_code pre {
margin: 0px;
}
span.citem {
display: table-cell;
text-align: center
}
div.devel-remark {
font-style: italic;
color: #800;
margin: 1ex 0;
}
div.downloads h4 {
min-height: 24px;
line-height: 24px;
background: transparent url(gnome-mime-application-x-archive.png) top left no-repeat;
padding-left: 26px;
}
div.downloads p.devhelp-note {
font-size: 80%;
}
div.downloads p.devhelp-note {
font-size: 80%;
color: #444;
}
p.canonical-ref {
padding: 0.5em 1em 0.5em 60px;
min-height: 48px;
border: solid 1px #e0e0df;
margin-right: 29ex;
background-color: #fffff0;
background-position: 6px 0.5em;
background-repeat: no-repeat;
background-image: url(/skin/admon-note.png);
}
p.other-versions {
font-size: 80%;
color: #888;
}
p.other-versions a {
text-decoration: none;
}
.programlisting
{
background: #eef;
border: solid 1px #aaf;
padding: 0.5em;
}
.variablelist
{
padding: 4px;
margin-left: 3em;
}
.variablelist td:first-child
{
vertical-align: top;
}
.variablelist p {
margin: 0;
}
.listing_lines, .listing_code {
margin-top: 0px;
margin-bottom: 0px;
padding: 0.5em;
}
.listing_lines {
/* tango:sky blue 0.5 */
background: #a6c5e3;
/* tango:aluminium 6 */
color: #2e3436;
}
.listing_code {
/* tango:sky blue 0 */
background: #e6f3ff;
}
div.gtk-doc dt {
color: #2e3456;
margin: 0;
}
div.gtk-doc div.index dt {
line-height: 1.2;
font-size: 100%;
}
div.gtk-doc td.shortcuts {
background: white;
border: 1px solid #d3d7cf;
text-align: center;
}
div.gtk-doc span.refpurpose {
color: #555;
font-weight: normal;
}

755
data/xslt/eo_indexes.xsl Normal file
View File

@ -0,0 +1,755 @@
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
Copyright (c) 2006 Goran Rakic <grakic@devbase.net>.
This file is part of libgo.
libgo is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
libgo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with libgo; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:html="http://www.w3.org/1999/xhtml"
extension-element-prefixes="exsl"
version="1.0">
<xsl:import href="gettext.xsl"/>
<xsl:import href="heading.xsl"/>
<!-- This gets set on the command line ... -->
<xsl:param name="libgo.lang" select="''"/>
<xsl:param name="libgo.debug" select="false()"/>
<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:output method="html" encoding="UTF-8" indent="yes"
omit-xml-declaration="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
<xsl:namespace-alias stylesheet-prefix="html" result-prefix="#default"/>
<xsl:template name="footer">
<div id="footer">
<p>
Copyright © 2012 <a href="http://www.entrouvert.com/">Entr'ouvert</a>.
<br />
Hosted documents have their own copyright notices.
</p>
</div>
</xsl:template>
<xsl:template name="category-title">
<xsl:param name="lang"/>
<xsl:param name="tocid"/>
<xsl:variable name="rtocid">
<xsl:choose>
<xsl:when test="document('../externals/toc.xml')//toc[@id = $tocid]">
<xsl:value-of select="$tocid"/>
</xsl:when>
<!-- Rarian 0.8 changed all toc id; as library still needs to handle
older documents, here is a quick mapping -->
<xsl:when test="$tocid = 'index'">Core</xsl:when>
<xsl:when test="$tocid = 'ApplicationsAccessibility'">Accessibility</xsl:when>
<xsl:when test="$tocid = 'ApplicationsAccessories'">Utility</xsl:when>
<xsl:when test="$tocid = 'ApplicationsEducation'">Education</xsl:when>
<xsl:when test="$tocid = 'ApplicationsGames'">Game</xsl:when>
<xsl:when test="$tocid = 'ApplicationsGraphics'">Graphics</xsl:when>
<xsl:when test="$tocid = 'ApplicationsInternet'">Network</xsl:when>
<xsl:when test="$tocid = 'ApplicationsOffice'">Office</xsl:when>
<xsl:when test="$tocid = 'ApplicationsOther'">Other</xsl:when>
<xsl:when test="$tocid = 'DesktopApplets'">Other</xsl:when>
<xsl:when test="$tocid = 'ApplicationsScientific'">Science</xsl:when>
<xsl:when test="$tocid = 'ApplicationsMultimedia'">AudioVideo</xsl:when>
<xsl:when test="$tocid = 'ApplicationsSystem'">System</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="document('../externals/toc.xml')//toc[@id = $rtocid]/title">
<xsl:variable name="cat-icon"
select="document('../externals/toc.xml')//toc[@id = $rtocid]/@icon"/>
<h2>
<xsl:attribute name="class">category<xsl:if test="$cat-icon != ''"
> cat-<xsl:value-of select="$cat-icon"/></xsl:if></xsl:attribute>
<xsl:if test="$cat-icon != ''">
<xsl:attribute name="id"><xsl:value-of select="$cat-icon"/></xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="document('../externals/toc.xml')//toc[@id = $rtocid]/title[@xml:lang = $lang]">
<xsl:value-of select="document('../externals/toc.xml')//toc[@id = $rtocid]/title[@xml:lang = $lang]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="document('../externals/toc.xml')//toc[@id = $rtocid]/title"/>
</xsl:otherwise>
</xsl:choose>
</h2>
</xsl:when>
<xsl:otherwise>
<h2 class="category cat-{$tocid}" id="{$tocid}">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="$tocid"/></xsl:call-template>
</h2>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="language-label">
<xsl:param name="lang"/>
<xsl:choose>
<xsl:when test="document('../languages.xml')//lang[@code = $lang]">
<xsl:value-of select="document('../languages.xml')//lang[@code =
$lang]"/>
</xsl:when>
<xsl:when test="document('../languages.xml')//lang[substring(@code, 1, 2) = $lang]">
<xsl:value-of
select="document('../languages.xml')//lang[substring(@code, 1, 2) =
$lang]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$lang"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="subsection" mode="title">
<xsl:param name="lang"/>
<xsl:choose>
<xsl:when test="title[@xml:lang = $lang]">
<xsl:value-of select="title[@xml:lang = $lang]"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="title"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="subsection" mode="intro">
<xsl:param name="lang"/>
<xsl:if test="intro">
<p>
<xsl:choose>
<xsl:when test="intro[@xml:lang = $lang]">
<xsl:value-of select="intro[@xml:lang = $lang]"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="intro"/></xsl:otherwise>
</xsl:choose>
</p>
</xsl:if>
</xsl:template>
<xsl:template name="overlay-section-title">
<xsl:param name="lang"/>
<xsl:choose>
<xsl:when test="document('../overlay.xml')//subsection[@code = $lang]">
<xsl:value-of select="document('../languages.xml')//lang[@code =
$lang]"/>
</xsl:when>
<xsl:when test="document('../languages.xml')//lang[substring(@code, 1, 2) = $lang]">
<xsl:value-of
select="document('../languages.xml')//lang[substring(@code, 1, 2) =
$lang]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$lang"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="document" mode="channelindex">
<xsl:param name="ignoredeprecated" select="true()"/>
<xsl:param name="lang"/>
<xsl:if test="not($ignoredeprecated) or not(keywords/keyword[. = 'upcoming-deprecation'])">
<dt>
<xsl:if test="keywords/keyword[. = 'upcoming-deprecation']">
<xsl:attribute name="class">upcoming-deprecation</xsl:attribute>
</xsl:if>
<a lang="{@lang}">
<xsl:attribute name="href">
<xsl:if test="@path"><xsl:value-of select="@path"/></xsl:if>
<xsl:if test="@href"><xsl:value-of select="@href"/></xsl:if>
</xsl:attribute>
<xsl:if test="@href">
<xsl:attribute name="class">external</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="normalize-space(title)">
<xsl:value-of select="title" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@module" />
</xsl:otherwise>
</xsl:choose>
</a>
<xsl:if test="@path and versions/version">
<xsl:text> </xsl:text>
<span class="module-more">[<a href="{@modulename}/"><xsl:call-template
name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'more-versions-languages-or-options'"/></xsl:call-template></a>]</span>
</xsl:if>
<xsl:if test="@href">
<xsl:text> </xsl:text>
<span class="module-more">[<xsl:call-template
name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'external-resource'"/></xsl:call-template>]</span>
</xsl:if>
</dt>
<dd>
<xsl:if test="abstract">
<p><xsl:value-of select="abstract" /></p>
</xsl:if>
<xsl:if test="keywords/keyword[. = 'upcoming-deprecation']">
<p class="upcoming-deprecation">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'upcoming-deprecation'"/></xsl:call-template>
</p>
</xsl:if>
<xsl:if test="count(versions/version) > 1 and versions/version[@keyword = 'unstable']">
<p class="other-versions">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'see-also'"/></xsl:call-template><xsl:text> </xsl:text>
<a href="{@modulename}/unstable/" lang="{@lang}"><xsl:call-template
name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'development-version-doc'"/></xsl:call-template></a>
</p>
</xsl:if>
</dd>
</xsl:if>
</xsl:template>
<xsl:template match="document[@path != '' and (not(@single) or @single != 'true')]" mode="modindex">
<xsl:param name="lang"/>
<xsl:if test="concat('/', @channel, '/', @modulename, '/') != @path">
<!-- don't write document index if the document is not versioned -->
<xsl:variable name="modulename" select="@modulename"/>
<xsl:if test="$libgo.debug">
<xsl:message>Writing <xsl:value-of
select="concat(@modulename, '/index.html.', $lang)" /></xsl:message>
</xsl:if>
<exsl:document href="{@modulename}/index.html.{$lang}"
method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd">
<html lang="{$lang}">
<head>
<title><xsl:value-of select="title" /> -
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'gnome-developer-center'"/></xsl:call-template></title>
<xsl:call-template name="libgo.head">
<xsl:with-param name="channel" select="@channel"/>
</xsl:call-template>
<script type="text/javascript" src="/js/strings.js" />
</head>
<body class="with-star">
<xsl:call-template name="libgo.header">
<xsl:with-param name="channel">devel</xsl:with-param>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
<div id="container" class="page-wrapper">
<div class="container_12">
<div class="page_title">
<h1 class="article title"><a href="{@path}"
lang="{@lang}"><xsl:value-of select="title"/></a></h1>
</div>
<div class="content">
<xsl:if test="abstract">
<p>
<xsl:value-of select="abstract" />
</p>
</xsl:if>
<xsl:if test="keywords/keyword[. = 'upcoming-deprecation']">
<p class="upcoming-deprecation">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'upcoming-deprecation'"/></xsl:call-template>
</p>
</xsl:if>
<xsl:if test="versions">
<h4 class="versions">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'availableversions'"/></xsl:call-template>
</h4>
<ul class="versions">
<xsl:for-each select="versions/version">
<li>
<xsl:choose>
<xsl:when test="@keyword = 'stable'"><strong>
<a href="{@href}/" lang="{@lang}"><xsl:apply-templates
select="." mode="version-name"><xsl:with-param name="lang" select="$lang"/>
</xsl:apply-templates></a>
</strong>
</xsl:when>
<xsl:otherwise>
<a href="{@href}/" lang="{@lang}"><xsl:apply-templates
select="." mode="version-name"><xsl:with-param name="lang" select="$lang"/>
</xsl:apply-templates></a>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@keyword = 'unstable'">
(<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'development-version'"/></xsl:call-template>)
</xsl:if>
</li>
</xsl:for-each>
</ul>
<xsl:if test="@single_page_alternative = 'true'">
<h4><xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'allinonepage'"/></xsl:call-template></h4>
<ul class="versions">
<xsl:for-each select="versions/version">
<li>
<xsl:choose>
<xsl:when test="@keyword = 'stable'"><strong>
<a href="{@href}/{$modulename}.html" lang="{@lang}"><xsl:apply-templates
select="." mode="version-name"><xsl:with-param name="lang" select="$lang"/>
</xsl:apply-templates></a>
</strong>
</xsl:when>
<xsl:otherwise>
<a href="{@href}/{$modulename}.html" lang="{@lang}"><xsl:apply-templates
select="." mode="version-name"><xsl:with-param name="lang" select="$lang"/>
</xsl:apply-templates></a>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@keyword = 'unstable'">
(<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'development-version'"/></xsl:call-template>)
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:if>
</div>
<div class="sidebar">
<xsl:if test="tarballs">
<div class="downloads subtle_box">
<h4>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'downloads'"/></xsl:call-template>
</h4>
<ul>
<xsl:for-each select="tarballs/tarball">
<li><a href="{text()}"><xsl:value-of select="text()"/></a></li>
</xsl:for-each>
</ul>
<xsl:if test="keywords/keyword[. = 'gtk-doc']">
<p class="devhelp-note">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'devhelp-note'"/></xsl:call-template>
</p>
</xsl:if>
</div>
</xsl:if>
<xsl:if test="other-languages/lang">
<div class="other-languages subtle_box">
<script type="text/javascript" src="/js/language.js" />
<script type="text/javascript">display_missing_translation_text()</script>
</div>
</xsl:if>
<xsl:if test="@tarballname">
<div class="tarballname subtle_box">
<p>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'tarball-location'"/></xsl:call-template>
<xsl:text> </xsl:text>
<xsl:value-of select="@tarballname"/>
</p>
</div>
</xsl:if>
</div>
</div>
<div id="footer_art" class="default"> </div>
</div>
<xsl:call-template name="libgo.footer"/>
</body>
</html>
</exsl:document>
</xsl:if>
</xsl:template>
<xsl:template match="version" mode="version-name">
<xsl:param name="lang"/>
<xsl:choose>
<xsl:when test=". = 'nightly'">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'nightly-version'"/></xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="section" mode="channelindex">
<xsl:param name="lang"/>
<xsl:param name="hidetitle" value="false()"/>
<xsl:if test="not($hidetitle)">
<xsl:call-template name="category-title">
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="tocid" select="@toc_id"/>
</xsl:call-template>
</xsl:if>
<xsl:for-each select="section">
<xsl:sort select="format-number(@weight, '0.000')" order="descending"/>
<xsl:variable name="title" select="@title"/>
<xsl:if test="document">
<h3 class="subsection" id="{@title}">
<xsl:apply-templates select="document('../overlay.xml')//subsection[@id = $title]"
mode="title">
<xsl:with-param name="lang" select="$lang" />
</xsl:apply-templates>
</h3>
<xsl:apply-templates select="document('../overlay.xml')//subsection[@id = $title]"
mode="intro">
<xsl:with-param name="lang" select="$lang" />
</xsl:apply-templates>
<dl class="doc-index">
<xsl:for-each select="document">
<xsl:sort select="format-number(@weight, '0.000')" order="descending"/>
<xsl:sort select="translate(title, $ucletters, $lcletters)"/>
<xsl:apply-templates select="." mode="channelindex">
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="ignoredeprecated" select="true()"/>
</xsl:apply-templates>
</xsl:for-each>
</dl>
</xsl:if>
</xsl:for-each>
<xsl:if test="section and document">
<h3 class="subsection">
<xsl:call-template name="gettext">
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="msgid" select="'others'"/>
</xsl:call-template>
</h3>
</xsl:if>
<dl class="doc-index">
<xsl:for-each select="document">
<xsl:sort select="format-number(@weight, '0.000')" order="descending"/>
<xsl:sort select="translate(title, $ucletters, $lcletters)"/>
<xsl:apply-templates select="." mode="channelindex">
<xsl:with-param name="lang" select="$lang"/>
</xsl:apply-templates>
</xsl:for-each>
</dl>
</xsl:template>
<xsl:template match="index" mode="channelindex">
<div class="subindex" id="subindex-{@id}">
<h2><a href="{@id}"><xsl:value-of select="title"/></a></h2>
<xsl:if test="abstract">
<p><xsl:value-of select="abstract"/></p>
</xsl:if>
</div>
</xsl:template>
<xsl:template match="index" mode="toc">
<xsl:param name="lang" value="@lang"/>
<ul class="indextoc">
<xsl:for-each select="section">
<xsl:sort select="format-number(@weight, '0.000')" order="descending"/>
<li>
<a href="#{@toc_id}"><xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="@toc_id"/></xsl:call-template></a>
<xsl:if test="section">
<ul>
<xsl:for-each select="section">
<xsl:sort select="format-number(@weight, '0.000')" order="descending"/>
<xsl:if test="document">
<li>
<xsl:variable name="title" select="@title"/>
<a href="#{@title}"><xsl:apply-templates select="document('../overlay.xml')//subsection[@id = $title]"
mode="title">
<xsl:with-param name="lang" select="$lang" />
</xsl:apply-templates></a>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:for-each>
<xsl:if test="//keywords/keyword[. = 'upcoming-deprecation']">
<li><a href="deprecated">Deprecated APIs</a></li>
</xsl:if>
</ul>
</xsl:template>
<xsl:template match="index">
<xsl:param name="channel" select="@channel"/>
<xsl:param name="lang" select="@lang"/>
<xsl:param name="filename">
<xsl:choose>
<xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
<xsl:otherwise>more</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:if test="$libgo.debug">
<xsl:message>Writing channel: <xsl:value-of
select="concat($filename, '.html.', @lang)" /></xsl:message>
</xsl:if>
<xsl:apply-templates select="index" />
<exsl:document href="{$filename}.html.{@lang}"
method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd">
<html lang="{@lang}">
<head>
<title>
<xsl:choose>
<xsl:when test="@channel = 'users'">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'userslabel'"/></xsl:call-template>
-
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'gnome-developer-center'"/></xsl:call-template>
</xsl:when>
<xsl:when test="@channel = 'devel'">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'developerslabel'"/></xsl:call-template>
-
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'gnome-developer-center'"/></xsl:call-template>
</xsl:when>
<xsl:when test="@channel = 'admin'">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'sysadminslabel'"/></xsl:call-template>
-
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'gnome-developer-center'"/></xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'gnome-developer-center'"/></xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</title>
<xsl:call-template name="libgo.head">
<xsl:with-param name="channel" select="@channel"/>
</xsl:call-template>
<script type="text/javascript" src="/js/strings.js" />
</head>
<body class="with-star">
<xsl:call-template name="libgo.header">
<xsl:with-param name="channel">devel</xsl:with-param>
<xsl:with-param name="lang" select="@lang"/>
</xsl:call-template>
<div id="container" class="page-wrapper">
<div class="container_12">
<xsl:if test="title">
<div class="page_title"><h1 class="subindex" id="subindex-{@id}"><xsl:value-of select="title"/></h1></div>
</xsl:if>
<div class="content">
<xsl:apply-templates select="section" mode="channelindex">
<xsl:sort select="format-number(@weight, '0.000')" order="descending"/>
<xsl:sort select="translate(@toc_id, $ucletters, $lcletters)" />
<xsl:with-param name="lang" select="@lang"/>
<xsl:with-param name="hidetitle" select="count(section) = 1"/>
</xsl:apply-templates>
<xsl:apply-templates select="index" mode="channelindex">
<xsl:sort select="format-number(@weight, '0.000')" order="descending"/>
</xsl:apply-templates>
</div>
</div>
<div>
<xsl:attribute name="class">
sidebar
<xsl:if test="not(title)"> notitle</xsl:if>
</xsl:attribute>
<xsl:if test="@channel = 'users'">
<div id="usr" class="subtle_box">
<h2><span>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'userslabel'"/></xsl:call-template>
</span></h2>
<p>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'userstext'"/></xsl:call-template>
</p>
</div>
</xsl:if>
<xsl:if test="$filename = 'references'">
<div class="subtle_box">
<xsl:apply-templates select="." mode="toc">
<xsl:with-param name="lang" select="@lang"/>
</xsl:apply-templates>
</div>
</xsl:if>
<xsl:if test="@channel = 'devel'">
<div id="dev" class="subtle_box">
<h2><span>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'developerslabel'"/></xsl:call-template>
</span></h2>
<p>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'developerstext'"/></xsl:call-template>
</p>
</div>
</xsl:if>
<xsl:if test="@channel = 'admin'">
<div id="adm" class="subtle_box">
<h2><span>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'sysadminslabel'"/></xsl:call-template>
</span></h2>
<p>
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'sysadminstext'"/></xsl:call-template>
</p>
</div>
</xsl:if>
</div>
<div id="footer_art" class="default"> </div>
</div>
<xsl:call-template name="libgo.footer"/>
</body>
</html>
</exsl:document>
</xsl:template>
<xsl:template match="home">
<xsl:if test="$libgo.debug">
<xsl:message>Writing home: <xsl:value-of select="concat('index.html.', @lang)" /></xsl:message>
</xsl:if>
<exsl:document href="index.html.{@lang}"
method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd">
<html lang="{@lang}">
<head>
<title><xsl:call-template name="gettext"><xsl:with-param name="lang"
select="@lang"/><xsl:with-param name="msgid"
select="'gnome-developer-center'"/></xsl:call-template></title>
<xsl:call-template name="libgo.head"/>
<xsl:comment>[if IE]&gt;
&lt;style&gt;
div.body-sidebar { width: 100%; }
&lt;/style&gt;
&lt;![endif]</xsl:comment><xsl:text>
</xsl:text>
<script type="text/javascript" src="/js/strings.js" />
<link rel="stylesheet" type="text/css" media="all" href="/skin/960_24_col.css" />
<link rel="stylesheet" type="text/css" href="/skin/jquery.autocomplete.css"/>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.jcarousel.min.js"></script>
<script type="text/javascript" src="/js/jquery.autocomplete.js"></script>
</head>
<body class="with-star">
<xsl:call-template name="libgo.header">
<xsl:with-param name="channel">devel</xsl:with-param>
<xsl:with-param name="lang" select="@lang"/>
</xsl:call-template>
<div id="wrap">
<div id="container">
<div class="container_12">
<dl class="doc-index">
<xsl:for-each select="//document">
<xsl:sort select="format-number(@weight, '0.000')" order="descending"/>
<xsl:sort select="translate(title, $ucletters, $lcletters)"/>
<xsl:apply-templates select="." mode="channelindex">
<xsl:with-param name="lang" select="$libgo.lang"/>
<xsl:with-param name="ignoredeprecated" select="true()"/>
</xsl:apply-templates>
</xsl:for-each>
</dl>
</div>
</div>
</div>
<div id="footer_art" class="default"> </div>
<xsl:call-template name="libgo.footer"/>
</body>
</html>
</exsl:document>
</xsl:template>
<xsl:template match="indexes">
<xsl:apply-templates select="node()"/>
<xsl:for-each select="home">
<xsl:variable name="lang" select="@lang"/>
<xsl:apply-templates select="../index[@lang = $lang]//document" mode="modindex">
<xsl:with-param name="lang" select="$lang"/>
</xsl:apply-templates>
<xsl:apply-templates select=".." mode="nightly">
<xsl:with-param name="lang" select="$lang"/>
</xsl:apply-templates>
<xsl:apply-templates select=".." mode="deprecated">
<xsl:with-param name="lang" select="$lang"/>
</xsl:apply-templates>
</xsl:for-each>
<xsl:apply-templates select="." mode="languages"/>
<xsl:apply-templates select="home" mode="javascript"/>
</xsl:template>
</xsl:stylesheet>

View File

@ -13,188 +13,28 @@
<xsl:param name="channel"><xsl:value-of select="$libgo.channel"/></xsl:param>
<xsl:param name="lang"><xsl:value-of select="$libgo.lang"/></xsl:param>
<div class="page-wrapper">
<h1 id="logo"><a href="/"><img src="http://www.entrouvert.com/static/eo/img/logo.png" alt="Entr'ouvert"/></a> Entr'ouvert Documentation</h1>
</div>
<!-- accessibility access -->
<div id="accessibility_access">
<ul>
<li><a href="#container">Go to page content</a></li>
<li><a href="#top_bar">Go to main menu</a></li>
<li><a href="#s" onclick="$('#s').focus(); return false;">Go to the search field</a></li>
</ul>
</div>
<!-- global gnome.org domain bar -->
<div id="global_domain_bar">
<div class="maxwidth">
<div class="tab">
<a class="root" href="http://www.gnome.org/">GNOME.org</a>
</div>
</div>
</div>
<!-- header -->
<div id="header" class="container_12">
<div id="logo" class="grid_3">
<h1><a title="Go to home page" href="/"><img alt="GNOME: The Free Software Desktop Project">
<xsl:attribute name="src">
<xsl:choose>
<xsl:when test="$libgo.channel = 'devel'">/skin/gnome-logo-devcenter.png</xsl:when>
<xsl:otherwise>/skin/gnome-logo.png</xsl:otherwise>
</xsl:choose>
</xsl:attribute></img></a></h1>
</div>
<div id="top_bar" class="grid_9">
<div class="left">
<div class="menu-globalnav-container"><ul id="menu-globalnav" class="menu">
<li class="menu-item menu-item-type-post_type menu-item-6">
<xsl:if test="$channel = 'about'">
<xsl:attribute name="class">current-menu-item</xsl:attribute>
</xsl:if>
<a href="/about/"><xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'aboutlabel'"/></xsl:call-template>
</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-23">
<xsl:if test="$channel = 'users'">
<xsl:attribute name="class">current-menu-item</xsl:attribute>
</xsl:if>
<a href="http://library.gnome.org/users/"><xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'userslabel'"/></xsl:call-template>
</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-37">
<xsl:if test="$channel = 'devel'">
<xsl:attribute name="class">current-menu-item</xsl:attribute>
</xsl:if>
<a href="http://developer.gnome.org/"><xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'developerslabel'"/></xsl:call-template>
</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-40">
<xsl:if test="$channel = 'admin'">
<xsl:attribute name="class">current-menu-item</xsl:attribute>
</xsl:if>
<a href="http://library.gnome.org/admin/"><xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'sysadminslabel'"/></xsl:call-template>
</a>
</li>
</ul></div> </div>
<div class="right">
<form role="search" method="get" id="searchform">
<xsl:attribute name="action">
<xsl:if test="$channel = 'devel' and $libgo.dbm_support">/symbols/</xsl:if>
<xsl:if test="$channel != 'devel' or not($libgo.dbm_support)">http://www.google.com/custom</xsl:if>
</xsl:attribute>
<xsl:choose>
<xsl:when test="$channel = 'devel'">
<xsl:if test="not($libgo.dbm_support)">
<input type="hidden" name="domains" value="developer.gnome.org" />
<input type="hidden" name="sitesearch" value="developer.gnome.org" />
</xsl:if>
</xsl:when>
<xsl:otherwise>
<input type="hidden" name="domains" value="library.gnome.org" />
<input type="hidden" name="sitesearch" value="library.gnome.org" />
</xsl:otherwise>
</xsl:choose>
<div>
<label class="hidden" for="q">
<xsl:call-template name="gettext"><xsl:with-param name="lang"
select="$lang"/><xsl:with-param name="msgid"
select="'searchlabel'"/></xsl:call-template>:
</label><input type="text" value="" name="q" id="s" placeholder="Search" />
</div>
</form>
<xsl:if test="$channel = 'devel' and $libgo.dbm_support">
<script type="text/javascript">
$('#s').autocomplete('/symbols/lookup/',
{ minChars:3, matchSubset:1, matchContains:1, cacheLength:10,
selectOnly:1, rowsLimit:25 });
</script>
</xsl:if>
</div>
</div>
</div>
<div class="clearfix"></div>
</xsl:template>
<xsl:template name="libgo.head">
<xsl:param name="channel"><xsl:value-of select="$libgo.channel"/></xsl:param>
<link rel="stylesheet" type="text/css" media="all"
href="http://www.gnome.org/wp-content/themes/gnome-grass/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="/skin/lgo2010.css"/>
<!-- XXX <link media="print" rel="stylesheet" type="text/css" href="/skin/print.css"/> -->
<link rel="icon" type="image/png" href="/skin/gnome-16.png"/>
<link rel="SHORTCUT ICON" type="image/png" href="/skin/gnome-16.png"/>
<link rel="search" type="application/opensearchdescription+xml"
href="/gnome-library-search.xml" title="GNOME Library Search" />
<xsl:if test="$libgo.dbm_support and $channel = 'devel'">
<link rel="stylesheet" type="text/css" href="/skin/jquery.autocomplete.css"/>
<script type="text/javascript" src="/js/jquery.js" />
<script type="text/javascript" src="/js/jquery.autocomplete.js" />
</xsl:if>
href="http://www.entrouvert.com/static/eo/css/eo.css" />
<link rel="stylesheet" type="text/css" media="all" href="/skin/eo.css"/>
</xsl:template>
<xsl:template name="libgo.footer">
<div class="clearfix"></div>
<div id="footer_grass">   </div>
<div id="footer">
<div class="container_12">
<div class="links grid_9">
<div class="menu-footer-1-container"><ul id="menu-footer-1" class="menu"><li id="menu-item-88" class="menu-item menu-item-type-custom menu-item-home menu-item-88"><a href="http://www.gnome.org/">The GNOME Project</a>
<ul class="sub-menu">
<li id="menu-item-89" class="menu-item menu-item-type-post_type menu-item-89"><a href="http://www.gnome.org/about/">About Us</a></li>
<li id="menu-item-90" class="menu-item menu-item-type-custom menu-item-90"><a href="http://www.gnome.org/get-involved/">Get Involved</a></li>
<li id="menu-item-91" class="menu-item menu-item-type-custom menu-item-91"><a href="http://www.gnome.org/teams/">Teams</a></li>
<li id="menu-item-92" class="menu-item menu-item-type-custom menu-item-92"><a href="http://foundation.gnome.org">The GNOME Foundation</a></li>
<li><a href="http://www.gnome.org/support-gnome/">Support GNOME</a></li>
<li><a href="http://www.gnome.org/contact/">Contact</a></li>
</ul>
</li>
</ul></div>
<div class="menu-footer-2-container"><ul id="menu-footer-2" class="menu"><li id="menu-item-99" class="menu-item menu-item-type-post_type current-menu-item page_item page-item-20 current_page_item menu-item-99"><a href="#">Resources</a>
<ul class="sub-menu">
<li><a href="http://library.gnome.org">Documentation</a></li>
<li><a href="http://live.gnome.org">Wiki</a></li>
<li><a href="http://mail.gnome.org/mailman/listinfo">Mailing Lists</a></li>
<li><a href="http://live.gnome.org/GnomeIrcChannels">IRC Channels</a></li>
<li><a href="http://bugzilla.gnome.org/">Bug Tracker</a></li>
<li><a href="http://git.gnome.org/browse/">Development Code</a></li>
<li><a href="http://live.gnome.org/Jhbuild">Build Tool</a></li>
</ul>
</li>
</ul></div><div class="menu-footer-4-container"><ul id="menu-footer-4" class="menu"><li id="menu-item-104" class="menu-item menu-item-type-custom menu-item-104"><a href="http://www.gnome.org/news/">News</a>
<ul class="sub-menu">
<li><a href="http://www.gnome.org/start/stable">Latest Release</a></li>
<li><a href="http://planet.gnome.org">Planet GNOME</a></li>
<li><a href="http://gnomejournal.org">GNOME Journal</a></li>
<li><a href="http://news.gnome.org">Development News</a></li>
<li><a href="http://identi.ca/gnome/">Identi.ca</a></li>
<li><a href="http://twitter.com/gnome">Twitter</a></li>
</ul>
</li>
</ul></div></div>
<div class="links grid_3 right">
<div><ul class="menu available_languages"><li><strong>This website is available in many languages</strong><ul class="sub-menu"><li><a href="/languages" title="Switching Language">Switch Language</a></li></ul></li></ul>
<script type="text/javascript" src="/js/language.js" />
</div> </div>
<!-- footnotes -->
<div id="footnotes" class="grid_9">
Copyright © 20052011 <strong class="gnome_logo">The GNOME Project</strong><br />
<small>Optimised for standards. Hosted by <a href="http://redhat.com">Red Hat</a>.</small>
</div>
<div class="clear"></div>
</div>
</div>
</xsl:template>
</xsl:stylesheet>

508
src/doceo.py Executable file
View File

@ -0,0 +1,508 @@
#!/usr/bin/env python
#
# libgo - script to build library.gnome.org
# Copyright (C) 2007-2009 Frederic Peters
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
import os
import sys
import re
import tempfile
import urllib2
from cStringIO import StringIO
from optparse import OptionParser
import logging
try:
import elementtree.ElementTree as ET
except ImportError:
import xml.etree.ElementTree as ET
import tarfile
import stat
import subprocess
import dbm
import shutil
import socket
import __builtin__
data_dir = os.path.join(os.path.dirname(__file__), '../data')
__builtin__.__dict__['data_dir'] = data_dir
import errors
import utils
from utils import version_cmp, is_version_number
from document import Document
from overlay import Overlay
from modtypes.gnomedocbook import GnomeDocbookModule
from modtypes.gtkdoc import GtkDocModule
from modtypes.htmlfiles import HtmlFilesModule
from modtypes.mallard import MallardModule
from app import App
# timeout for downloads, so it doesn't hang on connecting to sourceforge
socket.setdefaulttimeout(10)
class Lgo(App):
'''Main Application Class'''
def run(self):
self.overlay = Overlay(os.path.join(data_dir, 'eo-overlay.xml'))
if self.options.rebuild_module:
self.rebuild_all = True
for doc_module in self.extract_modules(self.options.rebuild_module):
doc_module.process()
sys.exit(0)
if self.options.rebuild_remote:
self.generate_static_pages()
self.apply_overlay()
sys.exit(0)
self.copy_static_files()
if not self.options.skip_extra_tarballs:
self.process_extra_tarballs()
if self.config.nightly_tarballs_location:
self.process_nightly_tarballs()
self.apply_overlay()
self.generate_indexes()
self.generate_html_indexes()
self.generate_robots()
self.generate_sitemap()
self.generate_symbols_files()
self.generate_static_pages()
def process_modules(self):
'''Download GNOME releases'''
releases = self.ftp_gnome_org.listdir('pub/GNOME/teams/releng/')
releases = [x for x in releases if is_version_number(x)]
for i, r in enumerate(releases[:]):
if self.config.version_min and version_cmp(r, self.config.version_min) < 0:
continue
if self.config.version_max and version_cmp(r, self.config.version_max) > 0:
continue
if i < len(releases)-1 and releases[i+1].startswith(re.match(r'\d+\.\d+\.', r).group()) and \
not r == self.config.version_max:
# next release has the same major.minor version number, so skip
# this one and get the newer one later
logging.debug('skipping release %s, not the last in serie' % r)
continue
if int(r.split('.')[1]) % 2 == 1:
# odd release, development, skip unless this is the current
# development serie
if not releases[-1].startswith(re.match(r'\d+\.\d+\.', r).group()) and \
not r == self.config.version_max:
logging.debug('skipping release %s, not the last in serie' % r)
continue
if version_cmp(r, '2.19.0') < 0:
urls = ['pub/GNOME/teams/releng/%(r)s/gnome-%(r)s.modules']
elif version_cmp(r, '2.91.3') < 0:
urls = ['pub/GNOME/teams/releng/%(r)s/gnome-suites-%(r)s.modules']
else:
urls = ['pub/GNOME/teams/releng/%(r)s/gnome-apps-%(r)s.modules',
'pub/GNOME/teams/releng/%(r)s/gnome-suites-core-%(r)s.modules',
'pub/GNOME/teams/releng/%(r)s/gnome-suites-core-deps-%(r)s.modules']
logging.info('Getting GNOME release: %s' % r)
for url in urls:
try:
moduleset = self.ftp_gnome_org.download(url % {'r': r})[1]
except Exception, e:
logging.error('Failed retrieving %s (%s)' % (url % {'r': r}, str(e)))
continue
self.process_moduleset(moduleset, r)
if self.config.version_max is None and r == releases[-1]:
# this is the last release, and no maximum version was set,
# add all modules to extra tarballs, so development versions
# not shipped with latest GNOME are made available.
moduleset.seek(0)
self.process_latest_moduleset(moduleset)
def extract_modules(self, filename, nightly = False):
logging.debug('looking for doc modules in %s' % filename)
doc_modules = []
mtime = os.stat(filename)[stat.ST_MTIME]
if self.config.fast_mode:
ext_dirname = os.path.join(app.config.private_dir, 'extracts',
os.path.splitext(os.path.splitext(os.path.basename(filename))[0])[0])
stamp_file = ext_dirname + '.extract-stamp'
else:
stamp_file = None
base_tarball_name = os.path.basename(filename).rsplit('-', 1)[0]
if nightly:
stamp_file = None
if stamp_file and os.path.exists(stamp_file) and not os.path.exists(ext_dirname):
# file was extracted once, and no doc module were found inside
return []
elif stamp_file and os.path.exists(stamp_file) and os.stat(stamp_file)[stat.ST_MTIME] < mtime:
# file was extracted but has been modified since then, remove
# extraction if it exists:
if os.path.exists(ext_dirname):
logging.debug('removing old copy of files from %s' % base_tarball_name)
shutil.rmtree(ext_dirname, ignore_errors = True)
tar = tarfile.open(filename, 'r')
elif stamp_file and os.path.exists(stamp_file):
tar = utils.FakeTarFile(ext_dirname)
else:
tar = tarfile.open(filename, 'r')
doc_version = os.path.splitext(tar.name)[0].split('-')[-1]
if doc_version.endswith('.tar'):
doc_version = doc_version[:-4]
more_tarball_docs = self.overlay.more_tarball_docs.get(
base_tarball_name, [])[:]
for more_doc in more_tarball_docs:
# don't look for docs that require a newer version of the module
if 'minimum-version' in more_doc.attrib:
if version_cmp(doc_version, more_doc.attrib.get('minimum-version')) < 0:
more_tarball_docs.remove(more_doc)
extraction_happened = False
regex_gdu = re.compile(r'include.*gnome-doc-utils.make', re.DOTALL)
for tarinfo in tar:
doc = None
if os.path.split(tarinfo.name)[-1] in ('Makefile.am', 'GNUmakefile.am'):
fd = tar.extractfile(tarinfo)
makefile_am = fd.read()
# merge lines continued with \
makefile_am = re.sub(r'\\\s*\n', r' ', makefile_am)
if 'HELP_ID' in makefile_am and '@YELP_HELP_RULES@' in makefile_am:
if '.page' in makefile_am:
logging.debug('found usage of mallard (via YELP_HELP_RULES) in %s' % tarinfo.name)
doc = MallardModule.create_from_tar(tar, tarinfo, makefile_am, nightly)
else:
logging.debug('found usage of docbook (via YELP_HELP_RULES) in %s' % tarinfo.name)
doc = GnomeDocbookModule.create_from_tar(tar, tarinfo, makefile_am, nightly)
elif 'DOC_ID' in makefile_am and regex_gdu.findall(makefile_am):
logging.debug('found usage of mallard in %s' % tarinfo.name)
doc = MallardModule.create_from_tar(tar, tarinfo, makefile_am, nightly)
elif 'DOC_MODULE' in makefile_am and regex_gdu.findall(makefile_am):
logging.debug('found usage of docbook in %s' % tarinfo.name)
doc = GnomeDocbookModule.create_from_tar(tar, tarinfo, makefile_am, nightly)
elif 'include $(top_srcdir)/gtk-doc.make' in makefile_am or \
'include $(srcdir)/gtk-doc.make' in makefile_am or \
'include gtk-doc.make' in makefile_am or \
('gtkdoc-scan' in makefile_am and not 'gtk-doc' in tarinfo.name):
logging.debug('found usage of gtk-doc in %s' % tarinfo.name)
doc = GtkDocModule.create_from_tar(tar, tarinfo, makefile_am, nightly)
elif 'SUBDIRS = C' in makefile_am and \
os.path.basename(filename).startswith('gtk-doc-'):
logging.debug('found gtk-doc almost gnome-doc-utils manual in %s' % tarinfo.name)
makefile_am += '\nDOC_MODULE = gtk-doc-manual\n'
doc = GnomeDocbookModule.create_from_tar(tar, tarinfo, makefile_am, nightly)
else:
continue
if '$(' in doc.modulename:
continue
if not doc.modulename or doc.modulename in self.config.blacklist:
continue
else:
for more_doc in more_tarball_docs[:]:
if not tarinfo.isdir():
continue
directory_name = tarinfo.name
if not directory_name[-1] == '/':
directory_name += '/'
if directory_name.endswith(more_doc.attrib.get('dir')):
doc = HtmlFilesModule.create_from_tar(tar, tarinfo, more_doc)
more_tarball_docs.remove(more_doc)
continue
if doc:
doc.filename = filename
doc.mtime_tarball = mtime
if extraction_happened:
doc.extract(force=True)
else:
extraction_happened = doc.extract()
doc.setup_channel()
doc.path = self.get_module_web_path(doc)
if self.config.channels is None or doc.channel in self.config.channels:
doc_modules.append(doc)
else:
logging.debug('ignoring %s, not in an appropriate channel' % doc.modulename)
if more_tarball_docs:
for more_doc in more_tarball_docs:
logging.error('[%s] overlay file mentioned %s but it was not found' % \
(base_tarball_name, more_doc.attrib.get('dir')))
tar.close()
if stamp_file:
# touch extract stamp file
if not os.path.exists(ext_dirname):
os.makedirs(ext_dirname)
file(stamp_file, 'w').close()
return doc_modules
def process_extra_tarballs(self):
if self.config.extra_tarballs:
logging.info('processing extra tarballs')
for url in self.config.extra_tarballs:
logging.debug('processing extra tarball: %s' % url)
filename = self.download(url)
if not filename:
continue
if not type(filename) is list:
filename = [filename]
for fname in filename:
for doc_module in self.extract_modules(fname):
doc_module.process()
def process_nightly_tarballs(self):
logging.info('processing nightly tarballs')
for filename in os.listdir(self.config.nightly_tarballs_location):
if not (filename.endswith('.tar.gz') or filename.endswith('.tar.bz2') or
filename.endswith('.tar.xz')):
continue
filename = os.path.join(self.config.nightly_tarballs_location, filename)
for doc_module in self.extract_modules(filename, nightly = True):
doc_module.process()
def generate_indexes(self):
logging.info('generating indexes')
indexes = ET.Element('indexes')
# get all possible languages
languages = {}
for doc in self.documents:
for lang in doc.languages:
if lang == 'C':
continue # ignore
if self.config.languages and not lang in self.config.languages:
continue
languages[lang] = True
if 'sr@Latn' in languages and 'sr@latin' in languages:
del languages['sr@Latn']
for lang in languages.keys():
home = ET.SubElement(indexes, 'home')
home.set('lang', lang)
channels = self.config.channels
if not channels:
channels = ('users', 'devel', 'admin', 'misc')
for channel in channels:
docs = [x for x in self.documents if x.channel == channel]
if not docs:
continue
for lang in languages.keys():
logging.debug('generating index for lang %s' % lang)
sections = {}
for x in docs:
if x.toc_id is None:
logging.warning('doc %s has no toc id -> default to Other' % x.module)
x.toc_id = 'Other'
sections[x.toc_id] = True
sections = sections.keys()
sections.sort()
docs.sort(lambda x,y: cmp(x.title.get(lang), y.title.get(lang)))
subindexes = self.overlay.get_subindexes(channel)
if not subindexes:
index = ET.SubElement(indexes, 'index')
index.set('lang', lang)
index.set('channel', channel)
for section in sections:
section_docs = [x for x in docs if x.toc_id == section]
if not section_docs:
continue
self.create_section(index, section, section_docs, lang)
else:
remaining_sections = sections[:]
subindex_index = ET.SubElement(indexes, 'index')
subindex_index.set('lang', lang)
subindex_index.set('channel', channel)
for subindex in subindexes:
local_sections = [x for x in sections if x in subindex.sections]
if not local_sections:
continue
index = subindex.create_element(subindex_index,
channel, lang)
for section in local_sections:
remaining_sections.remove(section)
section_docs = [x for x in docs if x.toc_id == section]
if not section_docs:
continue
self.create_section(index, section, section_docs, lang)
if remaining_sections:
logging.warn('%s channel is missing some sections: %s' % (
channel, ', '.join(remaining_sections)))
self.indexes_tmp_file = tempfile.NamedTemporaryFile()
tree = ET.ElementTree(indexes)
tree.write(self.indexes_tmp_file.name)
if self.debug:
tree.write('/tmp/library-web-indexes.xml.%s' % os.getpid())
def create_section(self, index, section, section_docs, lang):
section_node = ET.SubElement(index, 'section')
section_node.set('toc_id', section)
section_node.set('weight', str(
self.overlay.get_section_weight(section)))
subsections = {}
for x in section_docs:
subsections[x.subsection] = True
subsections = subsections.keys()
for subsection in subsections:
subsection_docs = [x for x in section_docs if x.subsection == subsection]
if subsection is None:
parent_elem = section_node
else:
parent_elem = ET.SubElement(section_node, 'section')
parent_elem.set('title', subsection)
parent_elem.set('weight', str(
self.overlay.get_section_weight(subsection)))
for doc in subsection_docs:
logging.debug('generating index for module %s' % doc.module)
if lang in doc.languages:
# document is available in the requested
# language, perfect.
doc_lang = lang
elif lang[:2] in doc.languages:
# mapping to "general" language, for example
# from en_GB to en, from fr_BE to fr...
doc_lang = lang[:2]
elif [x for x in doc.languages if x[:2] == lang]:
# mapping to "country" language, for
# example from pt to pt_BR
doc_lang = [x for x in doc.languages if x[:2] == lang][0]
else:
# fallback to English
doc_lang = 'en'
doc.create_element(parent_elem, doc_lang,
original_language = lang)
def generate_from_indexes(self, xsl_filename):
idx_filename = self.indexes_tmp_file.name
cmd = ['xsltproc', '--output', self.config.output_dir,
'--nonet', '--xinclude', xsl_filename, idx_filename]
if self.debug:
cmd.insert(-2, '--param')
cmd.insert(-2, 'libgo.debug')
cmd.insert(-2, 'true()')
if self.config.symbols_dbm_filepath:
cmd.insert(-2, '--param')
cmd.insert(-2, 'libgo.dbm_support')
cmd.insert(-2, 'true()')
logging.debug('executing %s' % ' '.join(cmd))
rc = subprocess.call(cmd)
if rc != 0:
logging.warn('%s failed with error %d' % (' '.join(cmd), rc))
def generate_html_indexes(self):
logging.info('generating index.html files')
indexes_xsl_file = self.config.indexes_xsl_file or self.default_indexes_xsl_file
self.generate_from_indexes(indexes_xsl_file)
def generate_robots(self):
logging.info('generating robots.txt file')
robots_xsl_file = os.path.join(data_dir, 'xslt', 'robots.xsl')
self.generate_from_indexes(robots_xsl_file)
def generate_sitemap(self):
logging.info('generating sitemap file')
sitemap_xsl_file = os.path.join(data_dir, 'xslt', 'sitemap.xsl')
self.generate_from_indexes(sitemap_xsl_file)
def generate_static_pages(self):
try:
doc_linguas = re.findall(r'DOC_LINGUAS\s+=[\t ](.*)',
file(os.path.join(data_dir, 'pages', 'Makefile.am')).read())[0].split()
doc_linguas.append('C')
except IndexError:
doc_linguas = ['C']
if app.config.languages:
for lang in doc_linguas[:]:
if lang not in self.config.languages + ['C']:
doc_linguas.remove(lang)
web_output_dir = os.path.join(self.config.output_dir, 'about')
for lang in doc_linguas:
xml_file = os.path.join(os.path.join(data_dir, 'pages', lang, 'libgo.xml'))
if lang == 'C':
lang = 'en'
cmd = ['xsltproc', '--output', web_output_dir + '/',
'--nonet', '--xinclude',
'--stringparam', 'libgo.lang', lang,
'--stringparam', 'libgo.channel', 'about',
'--param', 'db2html.navbar.bottom', 'false()',
GnomeDocbookModule.db2html_xsl_file, xml_file]
logging.debug('executing %s' % ' '.join(cmd))
rc = subprocess.call(cmd)
if rc != 0:
logging.warn('%s failed with error %d' % (' '.join(cmd), rc))
def get_module_web_path(self, module, versioned=True):
base_path = self.config.doc_path_template % {
'channel': module.channel,
'module': module.modulename }
licence_modules = ['fdl', 'gpl', 'lgpl']
if module.modulename in licence_modules or versioned is False:
# special casing the licences, they do not go in a
# versioned path
return base_path
else:
return base_path + module.one_dot_version + '/'
def get_module_web_output_dir(self, module, versioned=True):
return os.path.join(self.config.output_dir,
self.get_module_web_path(module, versioned=versioned)[1:])
if __name__ == '__main__':
app = Lgo()
app.Document = Document
app.run()