예제 #1
0
 def testGetCommandMetaData(self):
   command_group = self.my_cli.top_element
   command = command_group.LoadSubElement('test-command')
   meta_data = render_document.CommandMetaData(flags=['--bool-flag',
                                                      '--non-bool-flag'])
   for flag in meta_data.flags:
     self.assertIn(flag, calliope_actions.GetCommandMetaData(command).flags)
  def Visit(self, node, parent, is_group):
    """Renders document file for each node in the CLI tree.

    Args:
      node: group/command CommandCommon info.
      parent: The parent Visit() return value, None at the top level.
      is_group: True if node is a group, otherwise its is a command.

    Returns:
      The parent value, ignored here.
    """

    if self._style == 'linter':
      meta_data = actions.GetCommandMetaData(node)
    else:
      meta_data = None
    command = node.GetPath()
    path = os.path.join(self._directory, '_'.join(command)) + self._suffix
    with files.FileWriter(path) as f:
      md = markdown.Markdown(node)
      render_document.RenderDocument(style=self._style,
                                     title=' '.join(command),
                                     fin=io.StringIO(md),
                                     out=f,
                                     command_metadata=meta_data)
    return parent