diff options
author | jond@google.com <jond@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 18:31:24 +0000 |
---|---|---|
committer | jond@google.com <jond@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 18:31:24 +0000 |
commit | 8fdc61556da4b470ac827c80da17fa7f151ce210 (patch) | |
tree | b28790dfc2fbf36dfe0f55618801742a3916a4ce /ppapi | |
parent | 9bf2a866f9fe33201e29a3b272b68ae49308ec2f (diff) | |
download | chromium_src-8fdc61556da4b470ac827c80da17fa7f151ce210.zip chromium_src-8fdc61556da4b470ac827c80da17fa7f151ce210.tar.gz chromium_src-8fdc61556da4b470ac827c80da17fa7f151ce210.tar.bz2 |
New header and footer (removed old ones) for devsite. New doxyfile pointing to these headers and footers. New removefiles script for removing unneeded files for devsite and new python script for cleaning up resulting doxygen output for devsite.
Review URL: https://chromiumcodereview.appspot.com/9126002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119091 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/cpp/documentation/Doxyfile | 2 | ||||
-rw-r--r-- | ppapi/cpp/documentation/doxy_cleanup.py | 142 | ||||
-rw-r--r-- | ppapi/cpp/documentation/footer.html | 6 | ||||
-rw-r--r-- | ppapi/cpp/documentation/header.html | 21 | ||||
-rwxr-xr-x | ppapi/cpp/documentation/removefilesCPP.sh | 22 |
5 files changed, 167 insertions, 26 deletions
diff --git a/ppapi/cpp/documentation/Doxyfile b/ppapi/cpp/documentation/Doxyfile index 72ca636..ac862da1 100644 --- a/ppapi/cpp/documentation/Doxyfile +++ b/ppapi/cpp/documentation/Doxyfile @@ -1,4 +1,4 @@ -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. diff --git a/ppapi/cpp/documentation/doxy_cleanup.py b/ppapi/cpp/documentation/doxy_cleanup.py new file mode 100644 index 0000000..9ed7ae6 --- /dev/null +++ b/ppapi/cpp/documentation/doxy_cleanup.py @@ -0,0 +1,142 @@ +#!/usr/bin/python + +# Copyright (c) 2012 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 cleans up the html files as emitted by doxygen so +that they are suitable for publication on a Google documentation site. +''' + +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 HTMLFixer(object): + '''This class cleans up the html strings as produced by Doxygen + ''' + + def __init__(self, html): + self.soup = BeautifulSoup(html) + + def FixTableHeadings(self): + '''Fixes the doxygen table headings. + + This includes: + - Using bare <h2> title row instead of row embedded in <tr><td> in table + - Putting the "name" attribute into the "id" attribute of the <tr> tag. + - Splitting up tables into multiple separate tables if a table + heading appears in the middle of a table. + + For example, this html: + <table> + <tr><td colspan="2"><h2><a name="pub-attribs"></a> + Data Fields List</h2></td></tr> + ... + </table> + + would be converted to this: + <h2>Data Fields List</h2> + <table> + ... + </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.string = tag.td.h2.a.next + tag.name = 'h2' + 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: + print "Header tag: %s is %s" % (tag.name, tag.string.strip()) + # Is this a heading in the middle of a table? + if tag.findPreviousSibling('tr') and tag.parent.name == 'table': + print "Splitting Table named %s" % tag.string.strip() + 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) + for index, row in enumerate(table.contents[tag_index:]): + new_table.insert(index, row) + # Now move the <h2> tag to be in front of the <table> tag + assert tag.parent.name == 'table' + table = tag.parent + table_parent = table.parent + table_index = table_parent.contents.index(table) + table_parent.insert(table_index, tag) + + 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 doxy_cleanup utility + + doxy_cleanup takes a list of html files and modifies them in place.''' + + 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() + + print "Processing %s" % filename + fixer = HTMLFixer(html) + fixer.FixAll() + with open(filename, '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()) diff --git a/ppapi/cpp/documentation/footer.html b/ppapi/cpp/documentation/footer.html index e6cbfe5..454a101 100644 --- a/ppapi/cpp/documentation/footer.html +++ b/ppapi/cpp/documentation/footer.html @@ -1,3 +1,5 @@ </div> <!-- id="doxygen-ref" --> -[endverbatim] -[include "/_boilerplate_footer.ezt"] + + </body> +</html> + diff --git a/ppapi/cpp/documentation/header.html b/ppapi/cpp/documentation/header.html index 7fe4ce6..89b99a9 100644 --- a/ppapi/cpp/documentation/header.html +++ b/ppapi/cpp/documentation/header.html @@ -1,14 +1,13 @@ -<!DOCTYPE html> -[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]$title[end] [# this is the title for only this page ] +{% include "native-client/_local_variables.html" %} +<html devsite> + <head> + <link href="/native-client/css/local_extensions.css" rel="stylesheet" type="text/css" /> + <title>$title</title> + <meta name="project_path" value="/native-client/_project.yaml" /> + <meta name="book_path" value="/native-client/_book.yaml" /> -[define css_includes] -<link href="../../../css/local_extensions.css" rel="stylesheet" type="text/css"/> -[end] + </head> + <body> -[include "/_boilerplate_header.ezt"] -[verbatim] <div id="doxygen-ref"> - <div>
\ No newline at end of file +<div>
\ No newline at end of file diff --git a/ppapi/cpp/documentation/removefilesCPP.sh b/ppapi/cpp/documentation/removefilesCPP.sh index f08f792..26e445e 100755 --- a/ppapi/cpp/documentation/removefilesCPP.sh +++ b/ppapi/cpp/documentation/removefilesCPP.sh @@ -1,21 +1,20 @@ #!/bin/bash -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. -rm annotated.ezt + +rm annotated.html rm bc_s.png -rm classes.ezt +rm classes.html rm closed.png rm doxygen.png rm functions*.* rm globals*.* -rm group___c_p_p.ezt -rm index_8dox.ezt -rm modules.ezt -rm namespacemembers.ezt -rm namespacemembers_func.ezt -rm namespaces.ezt +rm index_8dox.html +rm namespacemembers.html +rm namespacemembers_func.html +rm namespaces.html rm nav_f.png rm nav_h.png rm open.png @@ -27,10 +26,9 @@ rm tab_s.png rm *.md5 rm *.map rm *.css -rm index.ezt -rm *.html +rm index.html rm jquery.js -rm hierarchy.ezt +rm hierarchy.html |