lasso/lasso/extract_sections.py

62 lines
2.0 KiB
Python
Raw Normal View History

Docs: change the doc production and lot of other fixes * lasso/Makefile.am: distribute extract_sections.py * docs/references/lasso/lasso.types.in: add missing class (mainly SAML2 and ID-WSF 1.0/2.0) from docs/references/lasso.types.in * lasso/xml/strings.h: add lots of documentation, or at least documentation template to strings constants. * id-ff/login.h: * saml-2.0/assertion_query.h: * xml/xml.h: document undocumented enumerations. * lasso/errors.h: add proper documentation about error codes. * lasso/errors.c: new version of the lasso_strerror function * lasso/build_strerror.py: update the script that generater lasso_strerror from the documentation comments. Remove usage of OFTYPE * lasso/id-ff/session.c: * lasso/id-ff/session.h: remove usage of oftype, prefer gtk-introspection annotations instead. * lasso/id-wsf/data_service.h: * lasso/id-wsf/data_service.c: do the same. Add a script to build lasso-sections.txt * lasso/extract_sections.py: this script parses header files and generated lasso-sections.txt content for GObject class descriptions. Add a template file for the lasso-section.txt file * docs/references/lasso-sections.txt.in: this file serves as a base for the generation of lasso-sections.txt Update docs/references/Makefile.am for generating lasso-sections.txt * docs/references/Makefile.am: always rebuild template, using out of source build directory is too weird without it. call new script extract_sections.py to regenerate lasso-sections.txt if header files changed. Update lasso.sgml file with all missing sections * docs/reference/lasso.sgml: add all missing sections, mainly objects from XML schemas. * docs/reference/lasso-sections.txt: update it * *.c: add section documentation to some files. * lasso/xml/strings.h: fix bad usage or docbook markup
2009-08-26 17:15:07 +02:00
#! /usr/bin/env python
import glob
import re
import sys
import os
import os.path
enable_wsf = False
if '-wsf' in sys.argv:
enable_wsf = True
if len(sys.argv) == 2+enable_wsf:
srcdir = sys.argv[1]
else:
srcdir = '.'
for root, dirs, files in os.walk(srcdir):
prefixes = list()
for file in files:
if file.endswith('.c'):
prefixes.append(os.path.splitext(file)[0])
for prefix in prefixes:
try:
header = open(os.path.join(root, prefix + '.h')).read()
implementation = open(os.path.join(root, prefix + '.c')).read()
exported_functions = re.findall('LASSO_EXPORT.*(lasso_\w*)', header)
normal_functions = sorted ([ x for x in exported_functions if not x.endswith('get_type') ])
get_type = [ x for x in exported_functions if x.endswith('get_type') ][0]
file_name = re.findall('lasso_(.*)_get_type', get_type)[0]
try:
macro_type = re.findall('LASSO_(\w*)_CLASS\(', header)[0]
except:
macro_type = None
try:
type = re.findall(r'^struct _(Lasso\w*)', header, re.MULTILINE)[0]
except:
type = None
types = re.findall('^} (Lasso\w*);', header)
def convert(x):
if '%s' in x:
return x % macro_type
else:
return x
if type and macro_type:
standard_decl = [ convert(x) for x in [ 'LASSO_%s', 'LASSO_IS_%s', 'LASSO_TYPE_%s', get_type, 'LASSO_%s_CLASS', 'LASSO_IS_%s_CLASS', 'LASSO_%s_GET_CLASS' ] ]
print
print '<SECTION>'
print '<FILE>%s</FILE>' % file_name
print '<TITLE>%s</TITLE>' % type
print type
for x in types + normal_functions:
print x
print '<SUBSECTION Standard>'
for x in standard_decl:
print x
print '</SECTION>'
except:
continue