summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authormball@google.com <mball@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 15:52:49 +0000
committermball@google.com <mball@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 15:52:49 +0000
commita15fcb778a2c7d4c188ddbf44edcca8b6a526e16 (patch)
tree1027fc921592285b72724da7cff33e210fb23896 /ppapi
parentcdc05ec939773ef32e249d43b6f7393ee985d1fe (diff)
downloadchromium_src-a15fcb778a2c7d4c188ddbf44edcca8b6a526e16.zip
chromium_src-a15fcb778a2c7d4c188ddbf44edcca8b6a526e16.tar.gz
chromium_src-a15fcb778a2c7d4c188ddbf44edcca8b6a526e16.tar.bz2
Added new utility name 'html2ezt.py' to fix-up Doxygen htmls files for EZT
BUG=None TEST=Manual testing Review URL: http://codereview.chromium.org/6976007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/documentation/Doxyfile8
-rw-r--r--ppapi/c/documentation/footer.html1
-rw-r--r--ppapi/c/documentation/header.html5
-rwxr-xr-xppapi/c/documentation/html2ezt.py135
4 files changed, 145 insertions, 4 deletions
diff --git a/ppapi/c/documentation/Doxyfile b/ppapi/c/documentation/Doxyfile
index 66d0f46..a942b85 100644
--- a/ppapi/c/documentation/Doxyfile
+++ b/ppapi/c/documentation/Doxyfile
@@ -1,3 +1,7 @@
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
# Doxyfile 1.7.2
# This file describes the settings to be used by the documentation system
@@ -25,7 +29,7 @@ DOXYFILE_ENCODING = UTF-8
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
-PROJECT_NAME = "Pepper (PPAPI)"
+PROJECT_NAME =
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
@@ -1607,7 +1611,7 @@ DOT_IMAGE_FORMAT = png
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
-DOT_PATH = /usr/local/graphviz-2.14/bin
+DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
diff --git a/ppapi/c/documentation/footer.html b/ppapi/c/documentation/footer.html
index d663a04..e6cbfe5 100644
--- a/ppapi/c/documentation/footer.html
+++ b/ppapi/c/documentation/footer.html
@@ -1,2 +1,3 @@
+</div> <!-- id="doxygen-ref" -->
[endverbatim]
[include "/_boilerplate_footer.ezt"]
diff --git a/ppapi/c/documentation/header.html b/ppapi/c/documentation/header.html
index 1cb87e6..7fe4ce6 100644
--- a/ppapi/c/documentation/header.html
+++ b/ppapi/c/documentation/header.html
@@ -2,12 +2,13 @@
[include "/chrome/nativeclient/_local_variables.ezt"] [# this file should be at root of your document hierarchy ]
[define section]docs[end] [# this should be "docs" if the file lives in the "Docs" section (top nav)]
[# Otherwise, it's "home," "articles," "download," or "terms" ]
-[define page_title][end] [# this is the title for only this page ]
+[define page_title]$title[end] [# this is the title for only this page ]
[define css_includes]
-<link href="../../../css/local_extensions.css" rel="stylesheet" type="text/css">
+<link href="../../../css/local_extensions.css" rel="stylesheet" type="text/css"/>
[end]
[include "/_boilerplate_header.ezt"]
[verbatim]
<div id="doxygen-ref">
+ <div> \ No newline at end of file
diff --git a/ppapi/c/documentation/html2ezt.py b/ppapi/c/documentation/html2ezt.py
new file mode 100755
index 0000000..bb7ca25
--- /dev/null
+++ b/ppapi/c/documentation/html2ezt.py
@@ -0,0 +1,135 @@
+#!/usr/bin/python
+
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+'''This utility converts the html files as emitted by doxygen into ezt files
+that are suitable for inclusion into Google code site.
+
+EZT stands for "EaZy Templating (for Python)". For more information, see
+http://code.google.com/p/ezt/
+'''
+
+import optparse
+import os
+import re
+import shutil
+import string
+import sys
+try:
+ from BeautifulSoup import BeautifulSoup, Tag
+except (ImportError, NotImplementedError):
+ print ("This tool requires the BeautifulSoup package "
+ "(see http://www.crummy.com/software/BeautifulSoup/).\n"
+ "Make sure that the file BeautifulSoup.py is either in this directory "
+ "or is available in your PYTHON_PATH")
+ raise
+
+
+class EZTFixer(object):
+ '''This class converts the html strings as produced by Doxygen into ezt
+ strings as used by the Google code site tools
+ '''
+
+ def __init__(self, html):
+ self.soup = BeautifulSoup(html)
+
+ def FixTableHeadings(self):
+ '''Fixes the doxygen table headings to EZT's liking.
+
+ This includes using <th> instead of <h2> for the heading, and putting
+ the "name" attribute into the "id" attribute of the <tr> tag.
+
+ For example, this html:
+ <tr><td colspan="2"><h2><a name="pub-attribs"></a>
+ Data Fields List</h2></td></tr>
+
+ would be converted to this:
+ <tr id="pub-attribs"><th colspan="2">Data Fields List</th></tr>
+
+ Also, this function splits up tables into multiple separate tables if
+ a table heading appears in the middle of a table.
+ '''
+
+ table_headers = []
+ for tag in self.soup.findAll('tr'):
+ if tag.td and tag.td.h2 and tag.td.h2.a and tag.td.h2.a['name']:
+ tag['id'] = tag.td.h2.a['name']
+ tag.td.string = tag.td.h2.a.next
+ tag.td.name = 'th'
+ table_headers.append(tag)
+
+ # reverse the list so that earlier tags don't delete later tags
+ table_headers.reverse()
+ # Split up tables that have multiple table header (th) rows
+ for tag in table_headers:
+ # Is this a heading in the middle of a table?
+ if tag.findPreviousSibling('tr') and tag.parent.name == 'table':
+ table = tag.parent
+ table_parent = table.parent
+ table_index = table_parent.contents.index(table)
+ new_table = Tag(self.soup, name='table', attrs=table.attrs)
+ table_parent.insert(table_index + 1, new_table)
+ tag_index = table.contents.index(tag)
+ new_table.contents = table.contents[tag_index:]
+ del table.contents[tag_index:]
+
+ def RemoveTopHeadings(self):
+ '''Removes <div> sections with a header, tabs, or navpath class attribute'''
+ header_tags = self.soup.findAll(
+ name='div',
+ attrs={'class' : re.compile('^(header|tabs[0-9]*|navpath)$')})
+ [tag.extract() for tag in header_tags]
+
+ def FixAll(self):
+ self.FixTableHeadings()
+ self.RemoveTopHeadings()
+
+ def __str__(self):
+ return str(self.soup)
+
+
+def main():
+ '''Main entry for the html2ezt utility
+
+ html2ezt takes a list of html files and creates a set of ezt files with
+ the same basename and in the same directory as the original html files.
+ Each new ezt file contains a file that is suitable for presentation
+ on Google Codesite using the EZT tool.'''
+
+ parser = optparse.OptionParser(usage='Usage: %prog [options] files...')
+
+ parser.add_option('-m', '--move', dest='move', action='store_true',
+ default=False, help='move html files to "original_html"')
+
+ options, files = parser.parse_args()
+
+ if not files:
+ parser.print_usage()
+ return 1
+
+ for filename in files:
+ try:
+ with open(filename, 'r') as file:
+ html = file.read()
+
+ fixer = EZTFixer(html)
+ fixer.FixAll()
+ new_name = re.sub(re.compile('\.html$'), '.ezt', filename)
+ with open(new_name, 'w') as file:
+ file.write(str(fixer))
+ if options.move:
+ new_directory = os.path.join(
+ os.path.dirname(os.path.dirname(filename)), 'original_html')
+ if not os.path.exists(new_directory):
+ os.mkdir(new_directory)
+ shutil.move(filename, new_directory)
+ except:
+ print "Error while processing %s" % filename
+ raise
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())