-
Andrea Spadaccini authored
lib/constants.py * add to each CV_E* tuple the documentation of the error code * add the DOCUMENTED_CONSTANTS constant for the doc preprocessor autotools/docpp * add a new directive class CONSTANTS_<kind>, that gets data from constants.DOCUMENTED_CONSTANTS lib/cmdlib.py * modify the code that unpacked the CV_E* tuples to ignore the documentation parameter Signed-off-by:
Andrea Spadaccini <spadaccio@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
3ac3f5e4
docpp 1.44 KiB
#!/usr/bin/python
#
# Copyright (C) 2011 Google Inc.
#
# 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.
"""Script to replace special directives in documentation.
"""
import re
import fileinput
from ganeti import query
from ganeti.build import sphinx_ext
_DOC_RE = re.compile(r"^@(?P<class>[A-Z_]+)_(?P<kind>[A-Z]+)@$")
_DOC_CLASSES_DATA = {
"CONSTANTS": (sphinx_ext.DOCUMENTED_CONSTANTS, sphinx_ext.BuildValuesDoc),
"QUERY_FIELDS": (query.ALL_FIELDS, sphinx_ext.BuildQueryFields),
}
def main():
for line in fileinput.input():
m = _DOC_RE.match(line)
if m:
fields_dict, builder = _DOC_CLASSES_DATA[m.group("class")]
fields = fields_dict[m.group("kind").lower()]
for i in builder(fields):
print i
else:
print line,
if __name__ == "__main__":
main()