123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- import sys, os, re
- sys.path.insert(0, os.path.abspath(os.path.join('..', "..")))
- sys.path.append(os.path.abspath('.'))
- graphviz_output_format = 'svg'
- from waflib import TaskGen
- from waflib.TaskGen import task_gen, feats
- exclude_taskgen = []
- def taskgen_method(func):
- exclude_taskgen.append(func.__name__)
- setattr(task_gen, func.__name__, func)
- fix_fun_doc(func)
- return func
- taskgen_method.__doc__ = TaskGen.taskgen_method.__doc__
- TaskGen.taskgen_method = taskgen_method
- def extension(*k):
- def deco(func):
- exclude_taskgen.append(func.__name__)
- setattr(task_gen, func.__name__, func)
- for x in k:
- task_gen.mappings[x] = func
- return func
- return deco
- extension.__doc__ = TaskGen.extension.__doc__
- TaskGen.extension = extension
- def fix_fun_doc(fun):
- try:
- if not fun.__doc__.startswith('\tTask generator method'):
- fun.__doc__ = '\tTask generator method\n\t\n' + (fun.__doc__ or '')
- except Exception as e:
- print("Undocumented function %r (%r)" % (fun.__name__, e))
- fun.__doc__ = ""
- def fixmeth(x):
- if x == 'process_source':
- return ":py:func:`waflib.TaskGen.process_source`"
- if x == 'process_rule':
- return ":py:func:`waflib.TaskGen.process_rule`"
- return ":py:func:`%s`" % x
- def fixfeat(x):
- app = '../'
- if x in ('*', 'subst'):
- app = ''
- return "`%s <%sfeaturemap.html#feature%s>`_" % (x=='*' and 'all' or x, app, x!='*' and '-'+x or '')
- def append_doc(fun, keyword, meths):
- if keyword == "feature":
- meths = [fixfeat(x) for x in meths]
- else:
- meths = [fixmeth(x) for x in meths]
- dc = ", ".join(meths)
- fun.__doc__ += '\n\t:%s: %s' % (keyword, dc)
- def feature(*k):
- def deco(func):
- exclude_taskgen.append(func.__name__)
- setattr(task_gen, func.__name__, func)
- for name in k:
- feats[name].update([func.__name__])
- fix_fun_doc(func)
- append_doc(func, 'feature', k)
-
- return func
- return deco
- feature.__doc__ = TaskGen.feature.__doc__
- TaskGen.feature = feature
- def before(*k):
- def deco(func):
- exclude_taskgen.append(func.__name__)
- setattr(task_gen, func.__name__, func)
- for fun_name in k:
- task_gen.prec[func.__name__].add(fun_name)
- fix_fun_doc(func)
- append_doc(func, 'before', k)
- return func
- return deco
- before.__doc__ = TaskGen.before.__doc__
- TaskGen.before = before
- def after(*k):
- def deco(func):
- exclude_taskgen.append(func.__name__)
- setattr(task_gen, func.__name__, func)
- for fun_name in k:
- task_gen.prec[fun_name].add(func.__name__)
- fix_fun_doc(func)
- append_doc(func, 'after', k)
- return func
- return deco
- after.__doc__ = TaskGen.after.__doc__
- TaskGen.after = after
- TaskGen.taskgen_method(TaskGen.to_nodes)
- TaskGen.feature('*')(TaskGen.process_source)
- TaskGen.feature('*')(TaskGen.process_rule)
- TaskGen.before('process_source')(TaskGen.process_rule)
- TaskGen.feature('seq')(TaskGen.sequence_order)
- TaskGen.extension('.pc.in')(TaskGen.add_pcfile)
- TaskGen.feature('subst')(TaskGen.process_subst)
- TaskGen.before('process_source','process_rule')(TaskGen.process_subst)
- from waflib.Task import Task
- Task.__dict__['post_run'].__doc__ = "Update the cache files (executed by threads). Override in subclasses."
- from waflib import Configure, Build, Errors
- confmeths = []
- def conf(f):
- def fun(*k, **kw):
- mandatory = True
- if 'mandatory' in kw:
- mandatory = kw['mandatory']
- del kw['mandatory']
- try:
- return f(*k, **kw)
- except Errors.ConfigurationError as e:
- if mandatory:
- raise e
- confmeths.append(f.__name__)
- f.__doc__ = "\tConfiguration Method bound to :py:class:`waflib.Configure.ConfigurationContext`\n" + (f.__doc__ or '')
- setattr(Configure.ConfigurationContext, f.__name__, fun)
- setattr(Build.BuildContext, f.__name__, fun)
- return f
- conf.__doc__ = Configure.conf.__doc__
- Configure.conf = conf
- Configure.ConfigurationContext.__doc__ = """
- Configure the project.
- Waf tools may bind new methods to this class::
- from waflib.Configure import conf
- @conf
- def myhelper(self):
- print("myhelper")
- def configure(ctx):
- ctx.myhelper()
- """
- tool_to_features = {}
- import os
- lst = [x.replace('.py', '') for x in os.listdir('../../waflib/Tools/') if x.endswith('.py')]
- for x in lst:
- if x == '__init__':
- continue
- tool = __import__('waflib.Tools.%s' % x)
- mod = tool.__dict__['Tools'].__dict__[x]
- dc = mod.__all__ = list(mod.__dict__.keys())
- excl = ['before', 'after', 'feature', 'taskgen_method', 'extension']
- if x != 'ccroot':
- excl += ['link_task', 'stlink_task']
- for k in excl:
- try:
- dc.remove(k)
- except:
- pass
- thetool = getattr(tool.Tools, x)
- funcs = dir(thetool)
- for func_name in funcs:
- thefunc = getattr(TaskGen.task_gen, func_name, None)
- if getattr(thefunc, "__name__", None) is None: continue
- for feat in TaskGen.feats:
- funcs = list(TaskGen.feats[feat])
- if func_name in funcs:
- if x not in tool_to_features:
- tool_to_features[x] = []
- tool_to_features[x].append(feat)
- txt = ""
- txt += "%s\n%s\n\n.. automodule:: waflib.Tools.%s\n\n" % (x, "="*len(x), x)
- if x in tool_to_features:
- txt += "Features defined in this module:"
- for feat in sorted(list(set(tool_to_features[x]))):
- link = "../featuremap.html#feature-%s" % feat
- txt += "\n\n* `%s <%s>`_" % (feat, link)
- try: old = open("tools/%s.rst" % x, "r").read()
- except: old = None
- if old != txt:
- with open("tools/%s.rst" % x, "w") as f:
- f.write(txt)
- lst = list(TaskGen.feats.keys())
- lst.sort()
- accu = []
- for z in lst:
- meths = TaskGen.feats[z]
- links = []
- allmeths = set(TaskGen.feats[z])
- for x, lst in TaskGen.task_gen.prec.items():
- if x in meths:
- for y in lst:
- links.append((x, y))
- allmeths.add(y)
- else:
- for y in lst:
- if y in meths:
- links.append((x, y))
- allmeths.add(x)
- color = ',fillcolor="#fffea6",style=filled'
- ms = []
- for x in allmeths:
- try:
- m = TaskGen.task_gen.__dict__[x]
- except KeyError:
- raise ValueError("undefined method %r" % x)
- k = "%s.html#%s.%s" % (m.__module__.split('.')[-1], m.__module__, m.__name__)
- if str(m.__module__).find('.Tools') > 0:
- k = 'tools/' + k
- k = '../' + k
- 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 ''))
- for x, y in links:
- ms.append('\t\t"%s" -> "%s" [arrowsize=0.5,style="setlinewidth(0.5)"];' % (x, y))
- rs = '\tdigraph feature_%s {\n\t\tsize="8.0, 12.0";\n%s\n\t}\n' % (z == '*' and 'all' or z, '\n'.join(ms))
- title = "Feature %s" % (z == '*' and '\\*' or z)
- title += "\n" + len(title) * '='
- accu.append("%s\n\n.. graphviz::\n\n%s\n\n" % (title, rs))
- f = open('featuremap.rst', 'w')
- f.write(""".. _featuremap:
- Feature reference
- =================
- .. include:: featuremap_example.txt
- """)
- f.write("\n".join(accu))
- f.close()
- confmeths.extend('find_program find_file find_perl_program cmd_to_list add_os_flags check_waf_version'.split())
- confmeths.sort()
- confmeths_dict = {}
- accu = []
- lst = [x.replace('.py', '') for x in os.listdir('../../waflib/Tools/') if x.endswith('.py')]
- for x in lst:
- if x == '__init__':
- continue
- tool = __import__('waflib.Tools.%s' % x)
- mod = tool.__dict__['Tools'].__dict__[x]
- dc = mod.__all__ = list(mod.__dict__.keys())
- thetool = getattr(tool.Tools, x)
- funcs = dir(thetool)
- for func_name in funcs:
- thefunc = getattr(Configure.ConfigurationContext, func_name, None)
- if getattr(thefunc, "__name__", None) is None: continue
- if thefunc:
- confmeths_dict[func_name] = x
- for x in confmeths:
- modname = confmeths_dict.get(x, '')
- if modname:
- d = 'tools/%s.html' % modname
- modname = 'Tools.' + modname
- else:
- modname = 'Configure'
- d = '%s.html' % modname
- accu.append('.. _%s: %s#waflib.%s.%s\n' % (x, d, modname, x))
- accu.append('* %s_\n' % x)
- f = open('confmap.rst', 'w')
- f.write(""".. _confmap:
- Configuration methods
- =====================
- .. include:: confmap_example.txt
- """)
- f.write("\n".join(accu))
- f.close()
- extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.imgmath', 'sphinx.ext.inheritance_diagram', 'sphinx.ext.graphviz', 'sphinx.ext.viewcode']
- templates_path = ['_templates']
- source_suffix = '.rst'
- master_doc = 'index'
- project = u'Waf'
- copyright = u'2005-2018, Thomas Nagy'
- with open('../../waflib/Context.py', 'r') as f:
- txt = f.read()
- m = re.compile('WAFVERSION=[\'"]([^\'"]+)', re.M).search(txt)
- version = release = m.group(1)
- exclude_patterns = []
- pygments_style = 'sphinx'
- try:
- from sphinx import version_info
- except ImportError:
- version_info = None
- if version_info and (1, 3) <= version_info:
- html_theme = 'classic'
- else:
- html_theme = 'default'
- html_logo = '_images/waf-64x64.png'
- html_static_path = ['_static']
- html_additional_pages = {'index':'indexcontent.html'}
- html_show_sphinx = False
- htmlhelp_basename = 'wafdoc'
- latex_elements = {
- 'papersize':'a4paper',
- }
- latex_documents = [
- ('index', 'waf.tex', u'waf Documentation',
- u'Thomas Nagy', 'manual'),
- ]
- man_pages = [
- ('index', 'waf', u'waf Documentation',
- [u'Thomas Nagy'], 1)
- ]
- autodoc_default_flags = ['members', 'show-inheritance']
- autodoc_member_order = 'bysource'
- def maybe_skip_member(app, what, name, obj, skip, options):
-
-
- if name in ('__doc__', '__module__', 'Nod3', '__weakref__'):
- return True
- global exclude_taskgen
- if what == 'class' and name in exclude_taskgen:
- return True
- if obj.__doc__:
- return False
- def setup(app):
- app.connect('autodoc-skip-member', maybe_skip_member)
|