Esempio n. 1
0
def reporters_command(
        alias=False,  # Print detailed information about the specified reporter.
        simple=False,  # Only print report aliases, without other information.
):
    """
    List available reports which dexy can run.
    """
    if simple:
        for reporter in dexy.reporter.Reporter:
            print(reporter.alias)

    elif alias:
        nodoc_settings = (
            'aliases',
            'help',
        )

        reporter = dexy.reporter.Reporter.create_instance(alias)

        print_indented("%s Reporter" % reporter.__class__.__name__)
        print('')

        print_indented("settings:")
        print('')
        for name in sorted(reporter._instance_settings):
            if name in nodoc_settings:
                continue

            docs, default_value = reporter._instance_settings[name]
            print_indented(name, 2)
            print_rewrapped(docs, 4)
            print_indented("(default: %r)" % default_value, 4)
            print('')

        reporter.help()

        print('')

    else:
        FMT = "%-15s %-9s %s"

        print(FMT % ('alias', 'default', 'info'))
        for reporter in dexy.reporter.Reporter:
            help_text = reporter.setting('help').splitlines()[0]
            default_text = reporter.setting('default') and 'true' or 'false'
            print(FMT % (reporter.alias, default_text, help_text))
Esempio n. 2
0
def reporters_command(
        alias=False, # Print detailed information about the specified reporter.
        simple=False, # Only print report aliases, without other information.
        ):
    """
    List available reports which dexy can run.
    """
    if simple:
        for reporter in dexy.reporter.Reporter:
            print reporter.alias

    elif alias:
        nodoc_settings = ('aliases', 'help',)

        reporter = dexy.reporter.Reporter.create_instance(alias)

        print_indented("%s Reporter" % reporter.__class__.__name__)
        print ''

        print_indented("settings:")
        print ''
        for name in sorted(reporter._instance_settings):
            if name in nodoc_settings:
                continue

            docs, default_value = reporter._instance_settings[name]
            print_indented(name, 2)
            print_rewrapped(docs, 4)
            print_indented("(default: %r)" % default_value, 4)
            print ''

        reporter.help()

        print ''

    else:
        FMT = "%-15s %-9s %s"
    
        print FMT % ('alias', 'default', 'info')
        for reporter in dexy.reporter.Reporter:
            help_text = reporter.setting('help').splitlines()[0]
            default_text = reporter.setting('default') and 'true' or 'false'
            print FMT % (reporter.alias, default_text, help_text)
Esempio n. 3
0
def info_command(
        __cli_options=False,
        expr="", # An expression partially matching document name.
        key="", # The exact document key.
        ws=False, # Whether to print website reporter keys and values.
        **kwargs
        ):
    """
    Prints metadata about a dexy document.

    Dexy must have already run successfully.

    You can specify an exact document key or an expression which matches part
    of a document name/key. The `dexy grep` command is available to help you
    search for documents and print document contents.
    """
    artifactsdir = kwargs.get('artifactsdir', defaults['artifacts_dir'])
    wrapper = init_wrapper(locals())
    wrapper.setup_log()
    batch = Batch.load_most_recent(wrapper)
    wrapper.batch = batch

    if expr:
        print "search expr:", expr
        matches = sorted([data for data in batch if expr in data.key],
                key=attrgetter('key'))
    elif key:
        matches = sorted([data for data in batch if key == data.key],
                key=attrgetter('key'))
    else:
        raise dexy.exceptions.UserFeedback("Must specify either expr or key")

    for match in matches:
        print ""
        print "  Info for Document '%s'" % match.key
        print ""
        print "  document output data type:", match.alias
        print ""

        print_indented("settings:", 2)
        for k in sorted(match._instance_settings):
            if not k in ('aliases', 'help'):
                print_indented("%s: %s" % (k, match.setting(k)), 4)

        print ""
        print_indented("attributes:", 2)
        for fname in sorted(info_attrs):
            print_indented("%s: %s" % (fname, getattr(match, fname)), 4)
        print ""
    
        print_indented("methods:", 2)
        for fname in sorted(info_methods):
            print_indented("%s(): %s" % (fname, getattr(match, fname)()), 4)
        print ""

        if storage_methods:
            print_indented("storage methods:", 2)
            for fname in sorted(storage_methods):
                print_indented("%s(): %s" % (fname, getattr(match.storage, fname)), 4)
            print ''

        if ws:
            print_indented("website reporter methods:", 2)
            print ''
            reporter = dexy.reporter.Reporter.create_instance('ws')
            reporter.wrapper = wrapper
            reporter.setup_navobj()
            reporter.help(match)
            print ''
            print_indented("active template plugins are:", 2)
            print_indented(", ".join(reporter.setting('plugins')), 4)
            print ''


        else:
            print_indented("For website reporter tags, run this command with -ws option", 4)
            print ''


        print_rewrapped("""For more information about methods available on this
        data type run `dexy datas -alias %s`""" % match.alias)
Esempio n. 4
0
def links_command(
        **kwargs
        ):
    """
    Print list of links and sections found in dexy documents.
    """
    artifactsdir = kwargs.get('artifactsdir', defaults['artifacts_dir'])
    wrapper = init_wrapper(locals())
    batch = Batch.load_most_recent(wrapper)

    if not batch:
        print "you need to run dexy first"
        sys.exit(1)

    wrapper.setup_log()
    wrapper.batch = batch

    wrapper.add_lookups()

    if wrapper.lookup_nodes:
        print_indented("Nodes:")
    for label in sorted(wrapper.lookup_nodes):
        nodes = wrapper.lookup_nodes[label]
        if len(nodes) > 1:
            print ''
            print_indented("'%s'" % label, 2)
            print_indented("Multiple nodes match %s:" % label, 4)
            for node in nodes:
                print_indented(">> %r" % node, 6)
        elif len(nodes) == 0:
            print_indented("'%s'" % label, 2)
            print_indented("NO nodes match %s" % label, 4)
        else:
            node = nodes[0]
            print_indented("'%s'" % label, 2)
            print_indented("%r" % node, 4)
        print ''

    print ''

    if wrapper.lookup_sections:
        print_indented("Sections:")
    for label in sorted(wrapper.lookup_sections):
        node = wrapper.lookup_sections[label][0]
        print_indented("'%s'" % label, 2)
        print_indented("%r" % node, 4)
        print ''
Esempio n. 5
0
    def help(self, data):
        nodoc = ('navobj', 'navigation',)
        print_indented("Website Template Environment Variables:", 4)
        print ''
        print_indented("Navigation and Content Related:", 6)
        env = self.website_specific_template_environment(data)
        for k in sorted(env):
            if k in nodoc:
                continue
            docs, value = env[k]
            print_indented("%s: %s" % (k, docs), 8)

        print ''
        navobj = env['navobj'][1]
        root = navobj.nodes['/']
        members = [(name, obj) for name, obj in inspect.getmembers(root)
                if not name.startswith('__')]

        print_indented("navobj Node attributes (using root node):", 6)
        print ''
        for member_name, member_obj in members:
            if not inspect.ismethod(member_obj):
                print_indented("%s: %r" % (member_name, member_obj), 8)
       
        print ''

        print_indented("navobj Node methods (using root node):", 6)
        print ''
        for member_name, member_obj in members:
            if inspect.ismethod(member_obj):
                print_indented("%s()" % (member_name), 8)
                print_indented("%s" % inspect.getdoc(member_obj), 10)
                print_indented("%s" % member_obj(), 10)
                print ''

        print ''
        print_indented("Variables From Plugins:", 6)
        env = self.run_plugins()
        for k in sorted(env):
            docs, value = env[k]
            print_indented("%s: %s" % (k, docs), 8)

        print ''
        print_indented("navobj Nodes:", 4)
        print_indented(navobj.debug(), 6)
Esempio n. 6
0
    def help(self, data):
        nodoc = (
            'navobj',
            'navigation',
        )
        print_indented("Website Template Environment Variables:", 4)
        print('')
        print_indented("Navigation and Content Related:", 6)
        env = self.website_specific_template_environment(data)
        for k in sorted(env):
            if k in nodoc:
                continue
            docs, value = env[k]
            print_indented("%s: %s" % (k, docs), 8)

        print('')
        navobj = env['navobj'][1]
        root = navobj.nodes['/']
        members = [(name, obj) for name, obj in inspect.getmembers(root)
                   if not name.startswith('__')]

        print_indented("navobj Node attributes (using root node):", 6)
        print('')
        for member_name, member_obj in members:
            if not inspect.ismethod(member_obj):
                print_indented("%s: %r" % (member_name, member_obj), 8)

        print('')

        print_indented("navobj Node methods (using root node):", 6)
        print('')
        for member_name, member_obj in members:
            if inspect.ismethod(member_obj):
                print_indented("%s()" % (member_name), 8)
                print_indented("%s" % inspect.getdoc(member_obj), 10)
                print_indented("%s" % member_obj(), 10)
                print('')

        print('')
        print_indented("Variables From Plugins:", 6)
        env = self.run_plugins()
        for k in sorted(env):
            docs, value = env[k]
            print_indented("%s: %s" % (k, docs), 8)

        print('')
        print_indented("navobj Nodes:", 4)
        print_indented(navobj.debug(), 6)