conf.py (16555B)
1 # -*- coding: utf-8 -*- 2 # 3 # waf documentation build configuration file, created by 4 # sphinx-quickstart on Sat Nov 6 20:46:09 2010. 5 # 6 # This file is execfile()d with the current directory set to its containing dir. 7 # 8 # Note that not all possible configuration values are present in this 9 # autogenerated file. 10 # 11 # All configuration values have a default; values that are commented out 12 # serve to show the default. 13 14 import sys, os, re 15 16 # If extensions (or modules to document with autodoc) are in another directory, 17 # add these directories to sys.path here. If the directory is relative to the 18 # documentation root, use os.path.abspath to make it absolute, like shown here. 19 sys.path.insert(0, os.path.abspath(os.path.join('..', ".."))) 20 sys.path.append(os.path.abspath('.')) 21 22 graphviz_output_format = 'svg' 23 24 html_theme_options = { 25 "body_min_width": "none", 26 "body_max_width": "none", 27 } 28 29 30 inheritance_graph_attrs = dict(rankdir="LR", size='""', fontsize=14, ratio='compress') 31 32 # monkey patch a few waf classes for documentation purposes! 33 #----------------------------------------------------------- 34 35 from waflib import TaskGen 36 from waflib.TaskGen import task_gen, feats 37 38 exclude_taskgen = [] 39 def taskgen_method(func): 40 exclude_taskgen.append(func.__name__) 41 setattr(task_gen, func.__name__, func) 42 fix_fun_doc(func) 43 return func 44 taskgen_method.__doc__ = TaskGen.taskgen_method.__doc__ 45 TaskGen.taskgen_method = taskgen_method 46 47 def extension(*k): 48 def deco(func): 49 exclude_taskgen.append(func.__name__) 50 setattr(task_gen, func.__name__, func) 51 for x in k: 52 task_gen.mappings[x] = func 53 return func 54 return deco 55 extension.__doc__ = TaskGen.extension.__doc__ 56 TaskGen.extension = extension 57 58 def fix_fun_doc(fun): 59 try: 60 if not fun.__doc__.startswith('\tTask generator method'): 61 fun.__doc__ = '\tTask generator method\n\t\n' + (fun.__doc__ or '') 62 except Exception as e: 63 print("Undocumented function %r (%r)" % (fun.__name__, e)) 64 fun.__doc__ = "" 65 66 def fixmeth(x): 67 if x == 'process_source': 68 return ":py:func:`waflib.TaskGen.process_source`" 69 if x == 'process_rule': 70 return ":py:func:`waflib.TaskGen.process_rule`" 71 return ":py:func:`%s`" % x 72 73 def fixfeat(x): 74 app = '../' 75 if x in ('*', 'subst'): 76 app = '' 77 return "`%s <%sfeaturemap.html#feature%s>`_" % (x=='*' and 'all' or x, app, x!='*' and '-'+x or '') 78 79 def append_doc(fun, keyword, meths): 80 81 if keyword == "feature": 82 meths = [fixfeat(x) for x in meths] 83 else: 84 meths = [fixmeth(x) for x in meths] 85 86 dc = ", ".join(meths) 87 fun.__doc__ += '\n\t:%s: %s' % (keyword, dc) 88 89 def feature(*k): 90 def deco(func): 91 exclude_taskgen.append(func.__name__) 92 setattr(task_gen, func.__name__, func) 93 for name in k: 94 feats[name].update([func.__name__]) 95 fix_fun_doc(func) 96 append_doc(func, 'feature', k) 97 #print "feature", name, k 98 return func 99 return deco 100 feature.__doc__ = TaskGen.feature.__doc__ 101 TaskGen.feature = feature 102 103 104 def before(*k): 105 def deco(func): 106 exclude_taskgen.append(func.__name__) 107 setattr(task_gen, func.__name__, func) 108 for fun_name in k: 109 task_gen.prec[func.__name__].add(fun_name) 110 fix_fun_doc(func) 111 append_doc(func, 'before', k) 112 return func 113 return deco 114 before.__doc__ = TaskGen.before.__doc__ 115 TaskGen.before = before 116 117 def after(*k): 118 def deco(func): 119 exclude_taskgen.append(func.__name__) 120 setattr(task_gen, func.__name__, func) 121 for fun_name in k: 122 task_gen.prec[fun_name].add(func.__name__) 123 fix_fun_doc(func) 124 append_doc(func, 'after', k) 125 return func 126 return deco 127 after.__doc__ = TaskGen.after.__doc__ 128 TaskGen.after = after 129 130 # replay existing methods 131 TaskGen.taskgen_method(TaskGen.to_nodes) 132 TaskGen.feature('*')(TaskGen.process_source) 133 TaskGen.feature('*')(TaskGen.process_rule) 134 TaskGen.before('process_source')(TaskGen.process_rule) 135 TaskGen.feature('seq')(TaskGen.sequence_order) 136 TaskGen.extension('.pc.in')(TaskGen.add_pcfile) 137 TaskGen.feature('subst')(TaskGen.process_subst) 138 TaskGen.before('process_source','process_rule')(TaskGen.process_subst) 139 140 from waflib.Task import Task 141 142 Task.__dict__['post_run'].__doc__ = "Update the cache files (executed by threads). Override in subclasses." 143 144 145 from waflib import Configure, Build, Errors 146 confmeths = [] 147 def conf(f): 148 def fun(*k, **kw): 149 mandatory = True 150 if 'mandatory' in kw: 151 mandatory = kw['mandatory'] 152 del kw['mandatory'] 153 154 try: 155 return f(*k, **kw) 156 except Errors.ConfigurationError as e: 157 if mandatory: 158 raise e 159 confmeths.append(f.__name__) 160 f.__doc__ = "\tConfiguration Method bound to :py:class:`waflib.Configure.ConfigurationContext`\n" + (f.__doc__ or '') 161 setattr(Configure.ConfigurationContext, f.__name__, fun) 162 setattr(Build.BuildContext, f.__name__, fun) 163 return f 164 conf.__doc__ = Configure.conf.__doc__ 165 Configure.conf = conf 166 167 Configure.ConfigurationContext.__doc__ = """ 168 Configure the project. 169 170 Waf tools may bind new methods to this class:: 171 172 from waflib.Configure import conf 173 @conf 174 def myhelper(self): 175 print("myhelper") 176 177 def configure(ctx): 178 ctx.myhelper() 179 """ 180 181 from waflib.Tools import asm 182 del asm.__dict__['link_task'] 183 del asm.__dict__['stlink_task'] 184 185 # Import all tools and build tool->feature map 186 tool_to_features = {} 187 import os 188 lst = [x.replace('.py', '') for x in os.listdir('../../waflib/Tools/') if x.endswith('.py')] 189 for x in lst: 190 if x == '__init__': 191 continue 192 tool = __import__('waflib.Tools.%s' % x) 193 194 mod = tool.__dict__['Tools'].__dict__[x] 195 dc = mod.__all__ = list(mod.__dict__.keys()) 196 197 excl = ['before', 'after', 'feature', 'taskgen_method', 'extension'] 198 if x != 'ccroot': 199 excl += ['link_task', 'stlink_task'] 200 for k in excl: 201 try: 202 dc.remove(k) 203 except: 204 pass 205 206 thetool = getattr(tool.Tools, x) 207 funcs = dir(thetool) 208 for func_name in funcs: 209 thefunc = getattr(TaskGen.task_gen, func_name, None) 210 if getattr(thefunc, "__name__", None) is None: continue 211 for feat in TaskGen.feats: 212 funcs = list(TaskGen.feats[feat]) 213 if func_name in funcs: 214 if x not in tool_to_features: 215 tool_to_features[x] = [] 216 tool_to_features[x].append(feat) 217 218 txt = "" 219 txt += "%s\n%s\n\n.. automodule:: waflib.Tools.%s\n :members:\n\n" % (x, "="*len(x), x) 220 if x in tool_to_features: 221 txt += "Features defined in this module:" 222 for feat in sorted(list(set(tool_to_features[x]))): 223 link = "../featuremap.html#feature-%s" % feat 224 txt += "\n\n* `%s <%s>`_" % (feat, link) 225 226 try: old = open("tools/%s.rst" % x, "r").read() 227 except: old = None 228 if old != txt: 229 with open("tools/%s.rst" % x, "w") as f: 230 f.write(txt) 231 232 lst = list(TaskGen.feats.keys()) 233 lst.sort() 234 235 accu = [] 236 for z in lst: 237 meths = TaskGen.feats[z] 238 links = [] 239 240 allmeths = set(TaskGen.feats[z]) 241 for x, lst in TaskGen.task_gen.prec.items(): 242 if x in meths: 243 for y in lst: 244 links.append((x, y)) 245 allmeths.add(y) 246 else: 247 for y in lst: 248 if y in meths: 249 links.append((x, y)) 250 allmeths.add(x) 251 252 color = ',fillcolor="#fffea6",style=filled' 253 ms = [] 254 for x in allmeths: 255 try: 256 m = TaskGen.task_gen.__dict__[x] 257 except KeyError: 258 raise ValueError("undefined method %r" % x) 259 260 k = "%s.html#%s.%s" % (m.__module__.split('.')[-1], m.__module__, m.__name__) 261 if str(m.__module__).find('.Tools') > 0: 262 k = 'tools/' + k 263 k = '../' + k 264 265 ms.append('\t\t"%s" [style="setlinewidth(0.5)",URL="%s",target="_top",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape="rectangle",fontsize=10%s];' % (x, k, x in TaskGen.feats[z] and color or '')) 266 267 for x, y in links: 268 ms.append('\t\t"%s" -> "%s" [arrowsize=0.5,style="setlinewidth(0.5)"];' % (x, y)) 269 270 #rs = '\tdigraph feature_%s {\n\t\tsize="8.0, 12.0";\n%s\n\t}\n' % (z == '*' and 'all' or z, '\n'.join(ms)) 271 rs = '\tdigraph feature_%s {\n\t\t\n%s\n\t}\n' % (z == '*' and 'all' or z, '\n'.join(ms)) 272 title = "Feature %s" % (z == '*' and '\\*' or z) 273 title += "\n" + len(title) * '=' 274 275 accu.append("%s\n\n.. graphviz::\n\n%s\n\n" % (title, rs)) 276 277 f = open('featuremap.rst', 'w') 278 f.write(""".. _featuremap: 279 280 Feature reference 281 ================= 282 283 .. include:: featuremap_example.txt 284 """) 285 f.write("\n".join(accu)) 286 f.close() 287 288 # now for the configuration methods 289 confmeths.extend('find_program find_file find_perl_program cmd_to_list add_os_flags check_waf_version'.split()) 290 confmeths.sort() 291 confmeths_dict = {} 292 accu = [] 293 lst = [x.replace('.py', '') for x in os.listdir('../../waflib/Tools/') if x.endswith('.py')] 294 for x in lst: 295 if x == '__init__': 296 continue 297 tool = __import__('waflib.Tools.%s' % x) 298 299 mod = tool.__dict__['Tools'].__dict__[x] 300 dc = mod.__all__ = list(mod.__dict__.keys()) 301 302 thetool = getattr(tool.Tools, x) 303 funcs = dir(thetool) 304 for func_name in funcs: 305 thefunc = getattr(Configure.ConfigurationContext, func_name, None) 306 if getattr(thefunc, "__name__", None) is None: continue 307 if thefunc: 308 confmeths_dict[func_name] = x 309 310 for x in confmeths: 311 modname = confmeths_dict.get(x, '') 312 if modname: 313 d = 'tools/%s.html' % modname 314 modname = 'Tools.' + modname 315 else: 316 modname = 'Configure' 317 d = '%s.html' % modname 318 319 accu.append('.. _%s: %s#waflib.%s.%s\n' % (x, d, modname, x)) 320 accu.append('* %s_\n' % x) 321 322 f = open('confmap.rst', 'w') 323 f.write(""".. _confmap: 324 325 Configuration methods 326 ===================== 327 328 .. include:: confmap_example.txt 329 330 """) 331 f.write("\n".join(accu)) 332 f.close() 333 334 335 #print("Path: %s" % sys.path) 336 337 # -- General configuration ----------------------------------------------------- 338 339 # If your documentation needs a minimal Sphinx version, state it here. 340 #needs_sphinx = '1.0' 341 342 # Add any Sphinx extension module names here, as strings. They can be extensions 343 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 344 extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.imgmath', 'sphinx.ext.inheritance_diagram', 'sphinx.ext.graphviz', 'sphinx.ext.viewcode'] 345 346 # Add any paths that contain templates here, relative to this directory. 347 templates_path = ['_templates'] 348 349 # The suffix of source filenames. 350 source_suffix = '.rst' 351 352 # The encoding of source files. 353 #source_encoding = 'utf-8-sig' 354 355 # The master toctree document. 356 master_doc = 'index' 357 358 # General information about the project. 359 project = u'Waf' 360 copyright = u'2005-2023, Thomas Nagy' 361 362 # The version info for the project you're documenting, acts as replacement for 363 # |version| and |release|, also used in various other places throughout the 364 # built documents. 365 # 366 # The short X.Y version. 367 #version = '1.8.10' 368 # The full version, including alpha/beta/rc tags. 369 #release = version 370 # 371 with open('../../waflib/Context.py', 'r') as f: 372 txt = f.read() 373 m = re.compile('WAFVERSION=[\'"]([^\'"]+)', re.M).search(txt) 374 version = release = m.group(1) 375 376 # The language for content autogenerated by Sphinx. Refer to documentation 377 # for a list of supported languages. 378 #language = None 379 380 # There are two options for replacing |today|: either, you set today to some 381 # non-false value, then it is used: 382 #today = '' 383 # Else, today_fmt is used as the format for a strftime call. 384 #today_fmt = '%B %d, %Y' 385 386 # List of patterns, relative to source directory, that match files and 387 # directories to ignore when looking for source files. 388 exclude_patterns = [] 389 390 # The reST default role (used for this markup: `text`) to use for all documents. 391 #default_role = None 392 393 # If true, '()' will be appended to :func: etc. cross-reference text. 394 #add_function_parentheses = True 395 396 # If true, the current module name will be prepended to all description 397 # unit titles (such as .. function::). 398 #add_module_names = True 399 400 # If true, sectionauthor and moduleauthor directives will be shown in the 401 # output. They are ignored by default. 402 #show_authors = False 403 404 # The name of the Pygments (syntax highlighting) style to use. 405 pygments_style = 'sphinx' 406 407 # A list of ignored prefixes for module index sorting. 408 #modindex_common_prefix = [] 409 410 411 # -- Options for HTML output --------------------------------------------------- 412 413 # The theme to use for HTML and HTML Help pages. See the documentation for 414 # a list of builtin themes. 415 try: 416 from sphinx import version_info 417 except ImportError: 418 version_info = None 419 if version_info and (1, 3) <= version_info: 420 html_theme = 'classic' 421 else: 422 html_theme = 'default' 423 424 # Theme options are theme-specific and customize the look and feel of a theme 425 # further. For a list of options available for each theme, see the 426 # documentation. 427 #html_theme_options = {} 428 429 # Add any paths that contain custom themes here, relative to this directory. 430 #html_theme_path = [] 431 432 # The name for this set of Sphinx documents. If None, it defaults to 433 # "<project> v<release> API documentation". 434 #html_title = None 435 436 # A shorter title for the navigation bar. Default is the same as html_title. 437 #html_short_title = None 438 439 # The name of an image file (relative to this directory) to place at the top 440 # of the sidebar. 441 html_logo = '_images/waf-64x64.png' 442 443 # The name of an image file (within the static path) to use as favicon of the 444 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 445 # pixels large. 446 #html_favicon = None 447 448 # Add any paths that contain custom static files (such as style sheets) here, 449 # relative to this directory. They are copied after the builtin static files, 450 # so a file named "default.css" will overwrite the builtin "default.css". 451 html_static_path = ['_static'] 452 453 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 454 # using the given strftime format. 455 #html_last_updated_fmt = '%b %d, %Y' 456 457 # If true, SmartyPants will be used to convert quotes and dashes to 458 # typographically correct entities. 459 #html_use_smartypants = True 460 461 # Custom sidebar templates, maps document names to template names. 462 #html_sidebars = {} 463 464 # Additional templates that should be rendered to pages, maps page names to 465 # template names. 466 html_additional_pages = {'index':'indexcontent.html'} 467 468 # If false, no module index is generated. 469 #html_domain_indices = True 470 471 # If false, no index is generated. 472 #html_use_index = True 473 474 # If true, the index is split into individual pages for each letter. 475 #html_split_index = False 476 477 # If true, links to the reST sources are added to the pages. 478 #html_show_sourcelink = True 479 480 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 481 html_show_sphinx = False 482 483 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 484 #html_show_copyright = True 485 486 # If true, an OpenSearch description file will be output, and all pages will 487 # contain a <link> tag referring to it. The value of this option must be the 488 # base URL from which the finished HTML is served. 489 #html_use_opensearch = '' 490 491 # This is the file name suffix for HTML files (e.g. ".xhtml"). 492 #html_file_suffix = None 493 494 # Output file base name for HTML help builder. 495 htmlhelp_basename = 'wafdoc' 496 497 498 # -- Options for LaTeX output -------------------------------------------------- 499 500 latex_elements = { 501 'papersize':'a4paper', 502 } 503 504 # Grouping the document tree into LaTeX files. List of tuples 505 # (source start file, target name, title, author, documentclass [howto/manual]). 506 latex_documents = [ 507 ('index', 'waf.tex', u'waf Documentation', 508 u'Thomas Nagy', 'manual'), 509 ] 510 511 # The name of an image file (relative to this directory) to place at the top of 512 # the title page. 513 #latex_logo = None 514 515 # For "manual" documents, if this is true, then toplevel headings are parts, 516 # not chapters. 517 #latex_use_parts = False 518 519 # If true, show page references after internal links. 520 #latex_show_pagerefs = False 521 522 # If true, show URL addresses after external links. 523 #latex_show_urls = False 524 525 # Additional stuff for the LaTeX preamble. 526 #latex_preamble = '' 527 528 # Documents to append as an appendix to all manuals. 529 #latex_appendices = [] 530 531 # If false, no module index is generated. 532 #latex_domain_indices = True 533 534 535 # -- Options for manual page output -------------------------------------------- 536 537 # One entry per manual page. List of tuples 538 # (source start file, name, description, authors, manual section). 539 man_pages = [ 540 ('index', 'waf', u'waf Documentation', 541 [u'Thomas Nagy'], 1) 542 ] 543 544 #autodoc_default_flags = ['members', 'no-undoc-members', 'show-inheritance'] 545 autodoc_default_flags = ['members', 'show-inheritance'] 546 autodoc_member_order = 'bysource' 547 548 def maybe_skip_member(app, what, name, obj, skip, options): 549 550 # from http://sphinx.pocoo.org/ext/autodoc.html#event-autodoc-skip-member 551 # param name: the fully qualified name of the object <- it is not, the name does not contain the module path 552 if name in ('__doc__', '__module__', 'Nod3', '__weakref__'): 553 return True 554 global exclude_taskgen 555 if what == 'class' and name in exclude_taskgen: 556 return True 557 if obj.__doc__: 558 return False 559 560 def setup(app): 561 app.connect('autodoc-skip-member', maybe_skip_member) 562