| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import cStringIO | 6 import cStringIO |
| 7 import fnmatch | 7 import fnmatch |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 VALID_CHANNELS = ('stable', 'beta', 'dev') | 13 VALID_CHANNELS = ('stable', 'beta', 'dev') |
| 14 | 14 |
| 15 ROOT_FILE_CONTENTS = """.. _pepper_%(channel)s_index: | 15 ROOT_FILE_CONTENTS = """\ |
| 16 .. _pepper_%(channel)s_index: |
| 17 |
| 16 | 18 |
| 17 :orphan: | 19 :orphan: |
| 18 | 20 |
| 19 .. DO NOT EDIT! This document is auto-generated by doxygen/rst_index.py. | 21 .. DO NOT EDIT! This document is auto-generated by doxygen/rst_index.py. |
| 20 | 22 |
| 21 ######################################## | 23 ######################################## |
| 22 Pepper API Reference (%(channel_title)s) | 24 Pepper API Reference (%(channel_title)s) |
| 23 ######################################## | 25 ######################################## |
| 24 | 26 |
| 25 This page lists the API for Pepper %(version)s. Apps that use this API can | 27 This page lists the API for Pepper %(version)s. Apps that use this API can |
| 26 run in Chrome %(version)s or higher. | 28 run in Chrome %(version)s or higher. |
| 27 | 29 |
| 28 :ref:`Pepper C API Reference <pepper_%(channel)s_c_index>` | 30 :ref:`Pepper C API Reference <pepper_%(channel)s_c_index>` |
| 29 =========================================================== | 31 =========================================================== |
| 30 | 32 |
| 31 :ref:`Pepper C++ API Reference <pepper_%(channel)s_cpp_index>` | 33 :ref:`Pepper C++ API Reference <pepper_%(channel)s_cpp_index>` |
| 32 =============================================================== | 34 =============================================================== |
| 33 | 35 |
| 34 """ | 36 """ |
| 35 | 37 |
| 36 C_FILE_CONTENTS = """.. _pepper_%(channel)s_c_index: | 38 C_FILE_CONTENTS = """\ |
| 39 .. _pepper_%(channel)s_c_index: |
| 40 .. _c-api%(channel_alt)s: |
| 37 | 41 |
| 38 .. DO NOT EDIT! This document is auto-generated by doxygen/rst_index.py. | 42 .. DO NOT EDIT! This document is auto-generated by doxygen/rst_index.py. |
| 39 | 43 |
| 40 ########################################## | 44 ########################################## |
| 41 Pepper C API Reference (%(channel_title)s) | 45 Pepper C API Reference (%(channel_title)s) |
| 42 ########################################## | 46 ########################################## |
| 43 | 47 |
| 44 This page lists the C API for Pepper %(version)s. Apps that use this API can | 48 This page lists the C API for Pepper %(version)s. Apps that use this API can |
| 45 run in Chrome %(version)s or higher. | 49 run in Chrome %(version)s or higher. |
| 46 | 50 |
| 47 `Interfaces <group___interfaces.html>`_ | 51 `Interfaces <pepper_%(channel)s/c/group___interfaces.html>`__ |
| 48 ======================================= | 52 ============================================================= |
| 49 %(interfaces)s | 53 %(interfaces)s |
| 50 | 54 |
| 51 `Structures <group___structs.html>`_ | 55 `Structures <pepper_%(channel)s/c/group___structs.html>`__ |
| 52 ==================================== | 56 ========================================================== |
| 53 %(structures)s | 57 %(structures)s |
| 54 | 58 |
| 55 `Functions <group___functions.html>`_ | 59 `Functions <pepper_%(channel)s/c/group___functions.html>`__ |
| 56 ===================================== | 60 =========================================================== |
| 57 | 61 |
| 58 `Enums <group___enums.html>`_ | 62 `Enums <pepper_%(channel)s/c/group___enums.html>`__ |
| 59 ============================= | 63 =================================================== |
| 60 | 64 |
| 61 `Typedefs <group___typedefs.html>`_ | 65 `Typedefs <pepper_%(channel)s/c/group___typedefs.html>`__ |
| 62 =================================== | 66 ========================================================= |
| 63 | 67 |
| 64 `Macros <globals_defs.html>`_ | 68 `Macros <pepper_%(channel)s/c/globals_defs.html>`__ |
| 65 ============================= | 69 =================================================== |
| 66 | 70 |
| 67 Files | 71 Files |
| 68 ===== | 72 ===== |
| 69 %(files)s | 73 %(files)s |
| 70 """ | 74 """ |
| 71 | 75 |
| 72 C_INTERFACE_WILDCARDS = ['struct_p_p_p__*', 'struct_p_p_b__*'] | 76 C_INTERFACE_WILDCARDS = ['struct_p_p_p__*', 'struct_p_p_b__*'] |
| 73 | 77 |
| 74 C_STRUCT_WILDCARDS = ['struct_p_p__*', 'union_p_p__*'] | 78 C_STRUCT_WILDCARDS = ['struct_p_p__*', 'union_p_p__*'] |
| 75 | 79 |
| 76 CPP_FILE_CONTENTS = """.. _pepper_%(channel)s_cpp_index: | 80 CPP_FILE_CONTENTS = """\ |
| 81 .. _pepper_%(channel)s_cpp_index: |
| 82 .. _cpp-api%(channel_alt)s: |
| 77 | 83 |
| 78 .. DO NOT EDIT! This document is auto-generated by doxygen/rst_index.py. | 84 .. DO NOT EDIT! This document is auto-generated by doxygen/rst_index.py. |
| 79 | 85 |
| 80 ############################################ | 86 ############################################ |
| 81 Pepper C++ API Reference (%(channel_title)s) | 87 Pepper C++ API Reference (%(channel_title)s) |
| 82 ############################################ | 88 ############################################ |
| 83 | 89 |
| 84 This page lists the C++ API for Pepper %(version)s. Apps that use this API can | 90 This page lists the C++ API for Pepper %(version)s. Apps that use this API can |
| 85 run in Chrome %(version)s or higher. | 91 run in Chrome %(version)s or higher. |
| 86 | 92 |
| 87 `Classes <inherits.html>`_ | 93 `Classes <pepper_%(channel)s/cpp/inherits.html>`__ |
| 88 ========================== | 94 ================================================== |
| 89 %(classes)s | 95 %(classes)s |
| 90 | 96 |
| 91 Files | 97 Files |
| 92 ===== | 98 ===== |
| 93 %(files)s | 99 %(files)s |
| 94 """ | 100 """ |
| 95 | 101 |
| 96 CPP_CLASSES_WILDCARDS = ['classpp_1_1*.html'] | 102 CPP_CLASSES_WILDCARDS = ['classpp_1_1*.html'] |
| 97 CPP_CLASSES_EXCLUDES = ['*-members*'] | 103 CPP_CLASSES_EXCLUDES = ['*-members*'] |
| 98 | 104 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 cap = False | 146 cap = False |
| 141 out += c | 147 out += c |
| 142 | 148 |
| 143 # Strip trailing version number (e.g. PPB_Audio_1_1 -> PPB_Audio) | 149 # Strip trailing version number (e.g. PPB_Audio_1_1 -> PPB_Audio) |
| 144 return re.sub(r'_\d_\d$', '', out) | 150 return re.sub(r'_\d_\d$', '', out) |
| 145 | 151 |
| 146 | 152 |
| 147 def GetPath(filepath): | 153 def GetPath(filepath): |
| 148 if os.path.exists(filepath): | 154 if os.path.exists(filepath): |
| 149 return filepath | 155 return filepath |
| 150 raise OSError('Couldnt find: ' + filepath) | 156 raise OSError('Couldn\'t find: ' + filepath) |
| 151 | 157 |
| 152 | 158 |
| 153 def MakeReSTListFromFiles(path, matches, excludes=None): | 159 def MakeReSTListFromFiles(prefix, path, matches, excludes=None): |
| 154 dir_files = os.listdir(path) | 160 dir_files = os.listdir(path) |
| 155 good_files = [] | 161 good_files = [] |
| 156 for match in matches: | 162 for match in matches: |
| 157 good_files.extend(fnmatch.filter(dir_files, match)) | 163 good_files.extend(fnmatch.filter(dir_files, match)) |
| 158 | 164 |
| 159 if excludes: | 165 if excludes: |
| 160 for exclude in excludes: | 166 for exclude in excludes: |
| 161 good_files = [filename for filename in good_files | 167 good_files = [filename for filename in good_files |
| 162 if not fnmatch.fnmatch(filename, exclude)] | 168 if not fnmatch.fnmatch(filename, exclude)] |
| 163 | 169 |
| 164 good_files.sort() | 170 good_files.sort() |
| 165 return '\n'.join(' * `%s <%s>`_\n' % (GetName(f), f) for f in good_files) | 171 return '\n'.join(' * `%s <%s/%s>`__\n' % (GetName(f), prefix, f) |
| 172 for f in good_files) |
| 166 | 173 |
| 167 | 174 |
| 168 def MakeTitleCase(s): | 175 def MakeTitleCase(s): |
| 169 return s[0].upper() + s[1:] | 176 return s[0].upper() + s[1:] |
| 170 | 177 |
| 178 def MakeChannelAlt(channel): |
| 179 if channel == 'stable': |
| 180 return '' |
| 181 else: |
| 182 return '-' + channel |
| 183 |
| 171 | 184 |
| 172 def GenerateRootIndex(channel, version, out_filename): | 185 def GenerateRootIndex(channel, version, out_filename): |
| 173 channel_title = MakeTitleCase(channel) | 186 channel_title = MakeTitleCase(channel) |
| 187 channel_alt = MakeChannelAlt(channel) |
| 174 | 188 |
| 175 # Use StringIO so we don't write out a partial file on error. | 189 # Use StringIO so we don't write out a partial file on error. |
| 176 output = cStringIO.StringIO() | 190 output = cStringIO.StringIO() |
| 177 output.write(ROOT_FILE_CONTENTS % vars()) | 191 output.write(ROOT_FILE_CONTENTS % vars()) |
| 178 | 192 |
| 179 with open(out_filename, 'w') as f: | 193 with open(out_filename, 'w') as f: |
| 180 f.write(output.getvalue()) | 194 f.write(output.getvalue()) |
| 181 | 195 |
| 182 | 196 |
| 183 def GenerateCIndex(root_dir, channel, version, out_filename): | 197 def GenerateCIndex(root_dir, channel, version, out_filename): |
| 184 interfaces = MakeReSTListFromFiles(root_dir, C_INTERFACE_WILDCARDS) | 198 prefix = 'pepper_%s/c' % channel |
| 185 structures = MakeReSTListFromFiles(root_dir, C_STRUCT_WILDCARDS) | 199 interfaces = MakeReSTListFromFiles(prefix, root_dir, C_INTERFACE_WILDCARDS) |
| 186 files = MakeReSTListFromFiles(root_dir, FILE_WILDCARDS) | 200 structures = MakeReSTListFromFiles(prefix, root_dir, C_STRUCT_WILDCARDS) |
| 201 files = MakeReSTListFromFiles(prefix, root_dir, FILE_WILDCARDS) |
| 187 channel_title = MakeTitleCase(channel) | 202 channel_title = MakeTitleCase(channel) |
| 203 channel_alt = MakeChannelAlt(channel) |
| 188 | 204 |
| 189 # Use StringIO so we don't write out a partial file on error. | 205 # Use StringIO so we don't write out a partial file on error. |
| 190 output = cStringIO.StringIO() | 206 output = cStringIO.StringIO() |
| 191 output.write(C_FILE_CONTENTS % vars()) | 207 output.write(C_FILE_CONTENTS % vars()) |
| 192 | 208 |
| 193 with open(out_filename, 'w') as f: | 209 with open(out_filename, 'w') as f: |
| 194 f.write(output.getvalue()) | 210 f.write(output.getvalue()) |
| 195 | 211 |
| 196 | 212 |
| 197 def GenerateCppIndex(root_dir, channel, version, out_filename): | 213 def GenerateCppIndex(root_dir, channel, version, out_filename): |
| 198 classes = MakeReSTListFromFiles(root_dir, CPP_CLASSES_WILDCARDS, | 214 prefix = 'pepper_%s/cpp' % channel |
| 215 classes = MakeReSTListFromFiles(prefix, root_dir, CPP_CLASSES_WILDCARDS, |
| 199 CPP_CLASSES_EXCLUDES) | 216 CPP_CLASSES_EXCLUDES) |
| 200 files = MakeReSTListFromFiles(root_dir, FILE_WILDCARDS) | 217 files = MakeReSTListFromFiles(prefix, root_dir, FILE_WILDCARDS) |
| 201 channel_title = MakeTitleCase(channel) | 218 channel_title = MakeTitleCase(channel) |
| 219 channel_alt = MakeChannelAlt(channel) |
| 202 | 220 |
| 203 # Use StringIO so we don't write out a partial file on error. | 221 # Use StringIO so we don't write out a partial file on error. |
| 204 output = cStringIO.StringIO() | 222 output = cStringIO.StringIO() |
| 205 output.write(CPP_FILE_CONTENTS % vars()) | 223 output.write(CPP_FILE_CONTENTS % vars()) |
| 206 | 224 |
| 207 with open(out_filename, 'w') as f: | 225 with open(out_filename, 'w') as f: |
| 208 f.write(output.getvalue()) | 226 f.write(output.getvalue()) |
| 209 | 227 |
| 210 | 228 |
| 211 def main(argv): | 229 def main(argv): |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 return 0 | 265 return 0 |
| 248 | 266 |
| 249 | 267 |
| 250 if __name__ == '__main__': | 268 if __name__ == '__main__': |
| 251 try: | 269 try: |
| 252 rtn = main(sys.argv[1:]) | 270 rtn = main(sys.argv[1:]) |
| 253 except KeyboardInterrupt: | 271 except KeyboardInterrupt: |
| 254 sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__)) | 272 sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__)) |
| 255 rtn = 1 | 273 rtn = 1 |
| 256 sys.exit(rtn) | 274 sys.exit(rtn) |
| OLD | NEW |