Example #1
0
  def _gen_options_reference(self):
    """Generate the options reference rst doc."""
    goals = gen_tasks_options_reference_data()
    filtered_goals = []
    omit_impl_regexps = [re.compile(r) for r in self.get_options().omit_impl_re]
    for g in goals:
      if any(r.match(t['impl']) for r in omit_impl_regexps for t in g.tasks):
        continue
      filtered_goals.append(g)
    glopts = gen_glopts_reference_data()

    # generate the .rst file
    template = resource_string(__name__,
                               os.path.join(self._templates_dir, 'options_reference.mustache'))
    filename = os.path.join(self._outdir, 'options_reference.rst')
    self.context.log.info('Generating {}'.format(filename))
    with safe_open(filename, 'wb') as outfile:
      generator = Generator(template, goals=filtered_goals, glopts=glopts)
      generator.write(outfile)

    # generate the .html file
    template = resource_string(__name__,
                               os.path.join(self._templates_dir, 'oref_html.mustache'))
    filename = os.path.join(self._outdir, 'options_reference.html')
    self.context.log.info('Generating {}'.format(filename))
    with safe_open(filename, 'wb') as outfile:
      generator = Generator(template, goals=filtered_goals, glopts=glopts)
      generator.write(outfile)
Example #2
0
  def _gen_options_reference(self):
    """Generate the options reference rst doc."""
    goals = gen_tasks_options_reference_data()
    filtered_goals = []
    omit_impl_regexps = [re.compile(r) for r in self.get_options().omit_impl_re]
    for g in goals:
      if any(r.match(t['impl']) for r in omit_impl_regexps for t in g.tasks):
        continue
      filtered_goals.append(g)
    glopts = gen_glopts_reference_data()

    # generate the .rst file
    template = resource_string(__name__,
                               os.path.join(self._templates_dir, 'options_reference.mustache'))
    filename = os.path.join(self._outdir, 'options_reference.rst')
    self.context.log.info('Generating %s' % filename)
    with safe_open(filename, 'wb') as outfile:
      generator = Generator(template, goals=filtered_goals, glopts=glopts)
      generator.write(outfile)

    # generate the .html file
    template = resource_string(__name__,
                               os.path.join(self._templates_dir, 'oref_html.mustache'))
    filename = os.path.join(self._outdir, 'options_reference.html')
    self.context.log.info('Generating %s' % filename)
    with safe_open(filename, 'wb') as outfile:
      generator = Generator(template, goals=filtered_goals, glopts=glopts)
      generator.write(outfile)
Example #3
0
 def test_gen_tasks_options_reference_data(self):
     # can we run our reflection-y goal code without crashing? would be nice
     Goal.by_name('jack').install(TaskRegistrar('jill', lambda: 42))
     oref_data = reflect.gen_tasks_options_reference_data()
     self.assertTrue(
         len(oref_data) > 0,
         'Tried to generate data for options reference, got emptiness')
  def DISABLED_test_gen_tasks_options_reference_data(self):
    # TODO(Eric Ayers) Not really part of the test, just to detect the cache poisoning
    before_support_dir = Config.from_cache().getdefault('pants_supportdir')

    # can we run our reflection-y goal code without crashing? would be nice
    Goal.by_name('jack').install(TaskRegistrar('jill', DummyTask))
    oref_data = reflect.gen_tasks_options_reference_data()

    # TODO(Eric Ayers) Not really part of the test, just to detect the cache poisoning
    after_support_dir = Config.from_cache().getdefault('pants_supportdir')
    self.assertEquals(before_support_dir, after_support_dir)

    self.assertTrue(len(oref_data) > 0,
                    'Tried to generate data for options reference, got emptiness')
Example #5
0
 def test_gen_tasks_options_reference_data(self):
   # Can we run our reflection-y goal code without crashing? would be nice.
   Goal.by_name('jack').install(TaskRegistrar('jill', DummyTask))
   oref_data = reflect.gen_tasks_options_reference_data()
   self.assertTrue(len(oref_data) > 0,
                   'Tried to generate data for options reference, got emptiness')