Exemplo n.º 1
0
 def Run(self, args):
     if args.devsite_dir:
         walker_util.DevSiteGenerator(self.cli, args.devsite_dir).Walk(
             args.hidden, args.restrict)
     if args.manpage_dir:
         walker_util.ManPageGenerator(self.cli, args.manpage_dir).Walk(
             args.hidden, args.restrict)
Exemplo n.º 2
0
 def Run(self, args):
   if args.devsite_dir:
     walker_util.DevSiteGenerator(self._cli_power_users_only,
                                  args.devsite_dir).Walk(
                                      args.hidden, args.restrict)
   if args.help_text_dir:
     walker_util.HelpTextGenerator(
         self._cli_power_users_only, args.help_text_dir).Walk(args.hidden,
                                                              args.restrict)
   if args.html_dir:
     walker_util.HtmlGenerator(
         self._cli_power_users_only, args.html_dir).Walk(args.hidden,
                                                         args.restrict)
     tree = walker_util.CommandTreeGenerator(
         self._cli_power_users_only).Walk(args.hidden, args.restrict)
     with io.open(os.path.join(args.html_dir, '_menu_.html'), 'wt') as out:
       WriteHtmlMenu(tree, out)
     for file_name in _HELP_HTML_DATA_FILES:
       with io.open(os.path.join(args.html_dir, file_name), 'wb') as out:
         file_contents = pkg_resources.GetResource(
             'googlecloudsdk.api_lib.meta.help_html_data.', file_name)
         out.write(file_contents)
   if args.manpage_dir:
     walker_util.ManPageGenerator(
         self._cli_power_users_only, args.manpage_dir).Walk(args.hidden,
                                                            args.restrict)
   if args.update_help_text_dir:
     # The help text golden files are always ascii.
     console_attr.ResetConsoleAttr(encoding='ascii')
     changes = help_util.HelpTextUpdater(
         self._cli_power_users_only, args.update_help_text_dir,
         test=args.test).Update(args.restrict)
     if changes and args.test:
       raise HelpTextOutOfDateError('Help text files must be updated.')
Exemplo n.º 3
0
 def Run(self, args):
     if args.devsite_dir:
         walker_util.DevSiteGenerator(self.cli, args.devsite_dir).Walk(
             args.hidden, args.restrict)
     if args.help_text_dir:
         walker_util.HelpTextGenerator(self.cli, args.help_text_dir).Walk(
             args.hidden, args.restrict)
     if args.html_dir:
         walker_util.HtmlGenerator(self.cli, args.html_dir).Walk(
             args.hidden, args.restrict)
         tree = walker_util.CommandTreeGenerator(self.cli).Walk(
             args.hidden, args.restrict)
         with open(os.path.join(args.html_dir, '_menu_.html'), 'w') as out:
             WriteHtmlMenu(tree, out)
         for file_name in _HELP_HTML_DATA_FILES:
             with open(os.path.join(args.html_dir, file_name), 'wb') as out:
                 file_contents = pkg_resources.GetResource(
                     'googlecloudsdk.api_lib.meta.help_html_data.',
                     file_name)
                 out.write(file_contents)
     if args.manpage_dir:
         walker_util.ManPageGenerator(self.cli, args.manpage_dir).Walk(
             args.hidden, args.restrict)
     if args.update_help_text_dir:
         changes = help_util.HelpTextUpdater(self.cli,
                                             args.update_help_text_dir,
                                             test=args.test).Update()
         if changes and args.test:
             raise HelpTextOutOfDateError(
                 'Help text files must be updated.')
Exemplo n.º 4
0
 def Run(self, args):
     if args.devsite_dir:
         walker_util.DevSiteGenerator(self.cli, args.devsite_dir).Walk(
             args.hidden, args.restrict)
     if args.html_dir:
         walker_util.HtmlGenerator(self.cli, args.html_dir).Walk(
             args.hidden, args.restrict)
         tree = walker_util.CommandTreeGenerator(self.cli).Walk(
             args.hidden, args.restrict)
         with open(os.path.join(args.html_dir, '_menu_.html'), 'w') as out:
             WriteHtmlMenu(tree, out)
         for file_name in _HELP_HTML_DATA_FILES:
             with open(os.path.join(args.html_dir, file_name), 'wb') as out:
                 file_contents = pkg_resources.GetResource(
                     'googlecloudsdk.api_lib.meta.help_html_data.',
                     file_name)
                 out.write(file_contents)
     if args.manpage_dir:
         walker_util.ManPageGenerator(self.cli, args.manpage_dir).Walk(
             args.hidden, args.restrict)
Exemplo n.º 5
0
  def testDevSiteGeneratorHiddenFileContents(self):
    """Tests the hidden DevSite _toc.yaml files, and two HTML files."""
    devsite_directory = os.path.join(self.temp_path, 'devsite')
    walker_util.DevSiteGenerator(self.cli, devsite_directory).Walk(hidden=True)

    files = {
        'alpha/sdk/hiddengroup/index.html': (True, """\
<html devsite="">
<head>
<title>gcloud alpha sdk hiddengroup</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
"""),
        'beta/sdk/subgroup/subgroup-command-2.html': (True, """\
<html devsite="">
<head>
<title>gcloud beta sdk subgroup subgroup-command-2</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
"""),
        'alpha/_toc.yaml': (False, """\
toc:
- title: "gcloud alpha"
  path: /sdk/gcloud/reference/alpha
  section:
  - title: "internal"
    path: /sdk/gcloud/reference/alpha/internal
    section:
    - title: "internal-command"
      path: /sdk/gcloud/reference/alpha/internal/internal-command
  - title: "sdk"
    path: /sdk/gcloud/reference/alpha/sdk
    section:
    - title: "alphagroup"
      path: /sdk/gcloud/reference/alpha/sdk/alphagroup
    - title: "hidden-command"
      path: /sdk/gcloud/reference/alpha/sdk/hidden-command
    - title: "hiddengroup"
      path: /sdk/gcloud/reference/alpha/sdk/hiddengroup
      section:
      - title: "hidden-command-2"
        path: /sdk/gcloud/reference/alpha/sdk/hiddengroup/hidden-command-2
      - title: "hidden-command-a"
        path: /sdk/gcloud/reference/alpha/sdk/hiddengroup/hidden-command-a
    - title: "ordered-choices"
      path: /sdk/gcloud/reference/alpha/sdk/ordered-choices
    - title: "second-level-command-1"
      path: /sdk/gcloud/reference/alpha/sdk/second-level-command-1
    - title: "second-level-command-b"
      path: /sdk/gcloud/reference/alpha/sdk/second-level-command-b
    - title: "subgroup"
      path: /sdk/gcloud/reference/alpha/sdk/subgroup
      section:
      - title: "subgroup-command-2"
        path: /sdk/gcloud/reference/alpha/sdk/subgroup/subgroup-command-2
      - title: "subgroup-command-a"
        path: /sdk/gcloud/reference/alpha/sdk/subgroup/subgroup-command-a
    - title: "xyzzy"
      path: /sdk/gcloud/reference/alpha/sdk/xyzzy
  - title: "version"
    path: /sdk/gcloud/reference/alpha/version
"""),
        'beta/_toc.yaml': (False, """\
toc:
- title: "gcloud beta"
  path: /sdk/gcloud/reference/beta
  section:
  - title: "internal"
    path: /sdk/gcloud/reference/beta/internal
    section:
    - title: "internal-command"
      path: /sdk/gcloud/reference/beta/internal/internal-command
  - title: "sdk"
    path: /sdk/gcloud/reference/beta/sdk
    section:
    - title: "betagroup"
      path: /sdk/gcloud/reference/beta/sdk/betagroup
      section:
      - title: "beta-command"
        path: /sdk/gcloud/reference/beta/sdk/betagroup/beta-command
      - title: "sub-command-2"
        path: /sdk/gcloud/reference/beta/sdk/betagroup/sub-command-2
      - title: "sub-command-a"
        path: /sdk/gcloud/reference/beta/sdk/betagroup/sub-command-a
    - title: "hidden-command"
      path: /sdk/gcloud/reference/beta/sdk/hidden-command
    - title: "hiddengroup"
      path: /sdk/gcloud/reference/beta/sdk/hiddengroup
      section:
      - title: "hidden-command-2"
        path: /sdk/gcloud/reference/beta/sdk/hiddengroup/hidden-command-2
      - title: "hidden-command-a"
        path: /sdk/gcloud/reference/beta/sdk/hiddengroup/hidden-command-a
    - title: "ordered-choices"
      path: /sdk/gcloud/reference/beta/sdk/ordered-choices
    - title: "second-level-command-1"
      path: /sdk/gcloud/reference/beta/sdk/second-level-command-1
    - title: "second-level-command-b"
      path: /sdk/gcloud/reference/beta/sdk/second-level-command-b
    - title: "subgroup"
      path: /sdk/gcloud/reference/beta/sdk/subgroup
      section:
      - title: "subgroup-command-2"
        path: /sdk/gcloud/reference/beta/sdk/subgroup/subgroup-command-2
      - title: "subgroup-command-a"
        path: /sdk/gcloud/reference/beta/sdk/subgroup/subgroup-command-a
    - title: "xyzzy"
      path: /sdk/gcloud/reference/beta/sdk/xyzzy
  - title: "version"
    path: /sdk/gcloud/reference/beta/version
"""),
        'internal/_toc.yaml': (False, """\
toc:
- title: "gcloud internal"
  path: /sdk/gcloud/reference/internal
  section:
  - title: "internal-command"
    path: /sdk/gcloud/reference/internal/internal-command
"""),
        'sdk/_toc.yaml': (False, """\
toc:
- title: "gcloud sdk"
  path: /sdk/gcloud/reference/sdk
  section:
  - title: "hidden-command"
    path: /sdk/gcloud/reference/sdk/hidden-command
  - title: "hiddengroup"
    path: /sdk/gcloud/reference/sdk/hiddengroup
    section:
    - title: "hidden-command-2"
      path: /sdk/gcloud/reference/sdk/hiddengroup/hidden-command-2
    - title: "hidden-command-a"
      path: /sdk/gcloud/reference/sdk/hiddengroup/hidden-command-a
  - title: "ordered-choices"
    path: /sdk/gcloud/reference/sdk/ordered-choices
  - title: "second-level-command-1"
    path: /sdk/gcloud/reference/sdk/second-level-command-1
  - title: "second-level-command-b"
    path: /sdk/gcloud/reference/sdk/second-level-command-b
  - title: "subgroup"
    path: /sdk/gcloud/reference/sdk/subgroup
    section:
    - title: "subgroup-command-2"
      path: /sdk/gcloud/reference/sdk/subgroup/subgroup-command-2
    - title: "subgroup-command-a"
      path: /sdk/gcloud/reference/sdk/subgroup/subgroup-command-a
  - title: "xyzzy"
    path: /sdk/gcloud/reference/sdk/xyzzy
"""),
        '_toc.yaml': (False, """\
toc:
- title: "gcloud Reference"
  path: /sdk/gcloud/reference
  section:
  - include: /sdk/gcloud/reference/alpha/_toc.yaml
  - include: /sdk/gcloud/reference/beta/_toc.yaml
  - include: /sdk/gcloud/reference/internal/_toc.yaml
  - include: /sdk/gcloud/reference/sdk/_toc.yaml
  - title: "gcloud version"
    path: /sdk/gcloud/reference/version
""")}
    for name, (contains, expected) in six.iteritems(files):
      path = os.path.join(devsite_directory, name)
      with open(path, 'r') as f:
        actual = f.read()
        self.CheckRegression(name, actual, expected, contains=contains)
Exemplo n.º 6
0
 def testDevSiteGeneratorHidden(self):
   """Tests the hidden DevSite generated directory file names and sizes."""
   devsite_directory = os.path.join(self.temp_path, 'devsite')
   walker_util.DevSiteGenerator(self.cli, devsite_directory).Walk(hidden=True)
   self.AssertDirectoryIsGolden(
       devsite_directory, __file__, 'walker_util', 'devsite-hidden.dir')