Пример #1
0
def main():

    long_description = """
    Provide documentation for modules, actors, and components.
    """

    default_format = 'compact' if sys.argv[0].endswith('csdocs') else 'detailed'

    argparser = argparse.ArgumentParser(description=long_description)
    group = argparser.add_mutually_exclusive_group()
    group.add_argument('what', metavar='<actor or module>', type=str, nargs='?', default='',
                       help='What to look up documentation for, if empty show top level documentation')
    group.add_argument('--all', action='store_const', const=True, default=False,
                       help='Generate complete actor documentation in Markdown format')
    argparser.add_argument('--format', default=default_format, choices=['detailed', 'compact', 'raw'],
                           help='Options "detailed" and "compact" returns Markdown-formatted text,'
                                ' while "raw" returns a JSON-formatted representation that can be'
                                ' used to generated the documentation in other formats.')

    args = argparser.parse_args()
    store = DocumentationStore()

    if args.all:
        all_docs()
    else:
        if args.format == 'raw':
            print json.dumps(store.help_raw(args.what))
        else:
            print store.help(args.what, args.format == 'compact')
Пример #2
0
def all_docs(what=None):
    ds = DocumentationStore()

    raw = ds.help_raw(what)
    print ds.help(what)

    for actor in raw.get('actors', []):
        print ds.help(what + '.' + actor)

    for module in raw.get('modules', []):
        all_docs(module)
def document(what):
    store = DocumentationStore()
    print store.help(what or None, compact=False, formatting='md', links=False)