Esempio n. 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=None,
        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 pretty-printed text,'
        ' while "raw" returns a JSON-formatted representation that can be'
        ' used to generated the documentation in other formats.')
    argparser.add_argument(
        '--prettyprinter',
        default='plain',
        choices=['plain', 'md'],
        help=
        'When "--format detailed" is in use, this options allows a choice between plain text and markdown'
    )

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

    if args.all:
        print store.documentation()
    else:
        if args.format == 'raw':
            print store.help_raw(args.what)
        else:
            compact = bool(args.format == 'compact')
            print store.help(args.what,
                             compact=compact,
                             formatting=args.prettyprinter)
Esempio n. 2
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')
Esempio n. 3
0
 def handle_get_actor_doc(self, handle, connection, match, data, hdr):
     """ Query ActorStore for documentation
     """
     path = match.group(1)
     what = '.'.join(path.strip('/').split('/'))
     ds = DocumentationStore()
     data = ds.help_raw(what)
     self.send_response(handle, connection, json.dumps(data))
Esempio n. 4
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)
Esempio n. 5
0
def handle_get_actor_doc(self, handle, connection, match, data, hdr):
    """
    GET /actor_doc {path}
    Get documentation in 'raw' format for actor or module at {path}
    Path is formatted as '/{module}/{submodule}/ ... /{actor}'.
    If {path} is empty return top-level documentation.
    See DocumentStore help_raw() for details on data format.
    Response status code: OK
    Response: dictionary with documentation
    """
    path = match.group(1)
    what = '.'.join(path.strip('/').split('/'))
    ds = DocumentationStore()
    what = None if not what else what
    data = ds.help_raw(what)
    self.send_response(handle, connection, data)
def handle_get_actor_doc(self, handle, connection, match, data, hdr):
    """
    GET /actor_doc/{path}
    Get documentation in 'raw' format for actor or module at {path}
    Path is formatted as '/{module}/{submodule}/ ... /{actor}'.
    If {path} is empty return top-level documentation.
    See DocumentStore help_raw() for details on data format.
    Response status code: OK
    Response: dictionary with documentation
    """
    path = match.group(1)
    what = '.'.join(path.strip('/').split('/'))
    ds = DocumentationStore()
    what = None if not what else what
    data = ds.help_raw(what)
    self.send_response(handle, connection, data)