def details(self, sym): """Show details of one symbol. :param sym: string like 'java_library' or 'artifact'.""" d = assemble_buildsyms(build_file_parser=self.context.build_file_parser) if not sym in d: return ["\nNo such symbol: {0}\n".format(sym)] template = resource_string(__name__, os.path.join(self._templates_dir, "cli_details.mustache")) spacey_render = pystache.render(template, d[sym]["defn"]) compact_render = re.sub("\n\n+", "\n\n", spacey_render) return compact_render.splitlines()
def list_all(self): d = assemble_buildsyms(build_file_parser=self.context.build_file_parser) max_sym_len = max(len(sym) for sym in d.keys()) console = [] blurb_template = resource_string(__name__, os.path.join(self._templates_dir, "cli_list_blurb.mustache")) for sym, data in sorted(d.items(), key=lambda (k, v): k.lower()): blurb = pystache.render(blurb_template, data) summary = re.sub("\s+", " ", blurb).strip() if len(summary) > 50: summary = summary[:47].strip() + "..." console.append("{0}: {1}".format(sym.rjust(max_sym_len), summary)) return console
def details(self, sym): '''Show details of one symbol. :param sym: string like 'java_library' or 'artifact'.''' d = assemble_buildsyms( build_file_parser=self.context.build_file_parser) if not sym in d: return ['\nNo such symbol: {0}\n'.format(sym)] template = resource_string( __name__, os.path.join(self._templates_dir, 'cli_details.mustache')) spacey_render = pystache.render(template, d[sym]['defn']) compact_render = re.sub('\n\n+', '\n\n', spacey_render) return compact_render.splitlines()
def list_all(self): d = assemble_buildsyms( build_file_parser=self.context.build_file_parser) max_sym_len = max(len(sym) for sym in d.keys()) console = [] blurb_template = resource_string( __name__, os.path.join(self._templates_dir, 'cli_list_blurb.mustache')) for sym, data in sorted(d.items(), key=lambda (k, v): k.lower()): blurb = pystache.render(blurb_template, data) summary = re.sub('\s+', ' ', blurb).strip() if len(summary) > 50: summary = summary[:47].strip() + '...' console.append('{0}: {1}'.format(sym.rjust(max_sym_len), summary)) return console
def _gen_build_dictionary(self): """Generate the BUILD dictionary reference rst doc.""" d = assemble_buildsyms(build_file_parser=self.context.build_file_parser) tocs = [tocl(d), jvm_sub_tocl(d), python_sub_tocl(d)] defns = [d[t]["defn"] for t in sorted(d.keys(), key=_lower)] # generate rst template = resource_string(__name__, os.path.join(self._templates_dir, "page.mustache")) filename = os.path.join(self._outdir, "build_dictionary.rst") self.context.log.info("Generating {}".format(filename)) with safe_open(filename, "wb") as outfile: generator = Generator(template, tocs=tocs, defns=defns) generator.write(outfile) # generate html template = resource_string(__name__, os.path.join(self._templates_dir, "bdict_html.mustache")) filename = os.path.join(self._outdir, "build_dictionary.html") self.context.log.info("Generating {}".format(filename)) with safe_open(filename, "wb") as outfile: generator = Generator(template, tocs=tocs, defns=defns) generator.write(outfile)
def _gen_build_dictionary(self): """Generate the BUILD dictionary reference rst doc.""" d = assemble_buildsyms( build_file_parser=self.context.build_file_parser) tocs = [tocl(d), jvm_sub_tocl(d), python_sub_tocl(d)] defns = [d[t]['defn'] for t in sorted(d.keys(), key=_lower)] # generate rst template = resource_string( __name__, os.path.join(self._templates_dir, 'page.mustache')) filename = os.path.join(self._outdir, 'build_dictionary.rst') self.context.log.info('Generating {}'.format(filename)) with safe_open(filename, 'wb') as outfile: generator = Generator(template, tocs=tocs, defns=defns) generator.write(outfile) # generate html template = resource_string( __name__, os.path.join(self._templates_dir, 'bdict_html.mustache')) filename = os.path.join(self._outdir, 'build_dictionary.html') self.context.log.info('Generating {}'.format(filename)) with safe_open(filename, 'wb') as outfile: generator = Generator(template, tocs=tocs, defns=defns) generator.write(outfile)
def setUp(self): super(ExtractedContentSanityTests, self).setUp() self._syms = reflect.assemble_buildsyms( build_file_parser=self.build_file_parser)
def setUp(self): super(BuildsymsSanityTests, self).setUp() self._syms = reflect.assemble_buildsyms(build_file_parser=self.build_file_parser)
def setUp(self): super(BuildsymsSanityTests, self).setUp() self._syms = reflect.assemble_buildsyms( build_file_parser=self.build_file_parser)
def setUp(self): super(ExtractedContentSanityTests, self).setUp() self._syms = reflect.assemble_buildsyms(build_file_parser=self.build_file_parser)