added overlay thingie, which allows to modify processed documents, used
* data/overlay.xml.in, data/Makefile.am, src/lgo.py: added overlay thingie, which allows to modify processed documents, used for the moment to add an abstract to GLib and GObject reference manuals. (will also be used to add external documents, but this part is just a stub at the moment) svn path=/trunk/; revision=65
This commit is contained in:
parent
5f498f4b0e
commit
808cbed3d2
11
ChangeLog
11
ChangeLog
|
@ -0,0 +1,11 @@
|
|||
2007-07-31 Frederic Peters <fpeters@0d.be>
|
||||
|
||||
* data/overlay.xml.in, data/Makefile.am, src/lgo.py: added overlay
|
||||
thingie, which allows to modify processed documents, used for the
|
||||
moment to add an abstract to GLib and GObject reference manuals.
|
||||
(will also be used to add external documents, but this part is just
|
||||
a stub at the moment)
|
||||
|
||||
2007-07-31 Frederic Peters <fpeters@0d.be>
|
||||
|
||||
* initial import.
|
|
@ -1,9 +1,8 @@
|
|||
catalogdir = $(datadir)/libgo
|
||||
catalog_in_files = catalog.xml.in
|
||||
catalog_DATA = $(catalog_in_files:.xml.in=.xml)
|
||||
data_in_files = catalog.xml.in overlay.xml.in
|
||||
data_DATA = $(data_in_files:.xml.in=.xml)
|
||||
@INTLTOOL_XML_RULE@
|
||||
|
||||
CLEAN_FILES = catalog.xml
|
||||
CLEAN_FILES = catalog.xml overlay.xml
|
||||
|
||||
EXTRA_DIST = $(catalog_in_files) $(catalog_DATA)
|
||||
EXTRA_DIST = $(data_in_files) $(data_DATA) languages.xml
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2007-07-31 Frederic Peters <fpeters@0d.be>
|
||||
|
||||
* POTFILES.in: added data/overlay.xml.in
|
||||
|
||||
2007-07-24 gettextize <bug-gnu-gettext@gnu.org>
|
||||
|
||||
* Makefile.in.in: New file, from gettext-0.16.1.
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# List of source files which contain translatable strings.
|
||||
data/catalog.xml.in
|
||||
data/overlay.xml.in
|
||||
|
|
42
src/lgo.py
42
src/lgo.py
|
@ -70,6 +70,40 @@ class Formatter(logging.Formatter):
|
|||
return '%c: %s' % (record.levelname[0], record.msg)
|
||||
|
||||
|
||||
class Overlay:
|
||||
def __init__(self, overlay_file):
|
||||
tree = ET.parse(overlay_file)
|
||||
self.modified_docs = {}
|
||||
self.new_docs = []
|
||||
|
||||
for doc in tree.findall('/documents/document'):
|
||||
if 'doc_module' in doc.attrib:
|
||||
# modifying an existing document
|
||||
self.modified_docs[(
|
||||
doc.attrib['doc_module'], doc.attrib['channel'])] = doc
|
||||
else:
|
||||
# new document
|
||||
self.new_docs.append(doc)
|
||||
|
||||
|
||||
def apply(self, document):
|
||||
key = (document.module, document.channel)
|
||||
overlay = self.modified_docs.get(key)
|
||||
if not overlay:
|
||||
return
|
||||
if overlay.find('title') is not None:
|
||||
for title in overlay.findall('title'):
|
||||
lang = title.attrib.get('xml:lang', 'en')
|
||||
document.title[lang] = title.text
|
||||
if overlay.find('abstract') is not None:
|
||||
for abstract in overlay.findall('abstract'):
|
||||
lang = abstract.attrib.get('xml:lang', 'en')
|
||||
document.abstract[lang] = abstract.text
|
||||
|
||||
def get_new_docs(self):
|
||||
return []
|
||||
|
||||
|
||||
class FtpDotGnomeDotOrg:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
@ -159,6 +193,7 @@ class Lgo:
|
|||
self.get_yelp_categories()
|
||||
self.copy_static_files()
|
||||
self.process_releases()
|
||||
self.apply_overlay()
|
||||
self.generate_indexes()
|
||||
self.generate_static_pages()
|
||||
|
||||
|
@ -616,6 +651,13 @@ class Lgo:
|
|||
tree = ET.parse(os.path.join(web_output_dir, '%s.devhelp' % doc_module))
|
||||
doc.title['en'] = tree.getroot().attrib['title']
|
||||
|
||||
def apply_overlay(self):
|
||||
logging.info('Applying overlay')
|
||||
overlay = Overlay(os.path.join(self.data_dir, 'overlay.xml'))
|
||||
for doc in self.documents:
|
||||
overlay.apply(doc)
|
||||
|
||||
self.documents.extend(overlay.get_new_docs())
|
||||
|
||||
def generate_indexes(self):
|
||||
indexes = ET.Element('indexes')
|
||||
|
|
Reference in New Issue