Skip to content

Commit

Permalink
Add group ordering system so Global Arguments is at the bottom again. (
Browse files Browse the repository at this point in the history
…Azure#832)

Unblock doc generation script so --ids show in the output and unicode characters don't fail the sphinx build.
  • Loading branch information
BurtBiel authored Sep 7, 2016
1 parent 8485468 commit 5cec7c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 4 additions & 3 deletions doc/sphinx/azhelpgen/azhelpgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from sphinx.util.compat import Directive
from sphinx.util.nodes import nested_parse_with_titles

from azure.cli.application import Application, Configuration
from azure.cli.application import APPLICATION, Configuration
import azure.cli._help as _help

app = Application(Configuration([]))
app = APPLICATION
try:
app.execute(['-h'])
except:
Expand Down Expand Up @@ -79,7 +79,8 @@ def run(self):
node.document = self.state.document
result = ViewList()
for line in self.make_rst():
result.append(line, '<azhelpgen>')
result.append(line.decode('utf-8', 'ignore'), '<azhelpgen>')

nested_parse_with_titles(self.state, result, node)
return node.children

Expand Down
10 changes: 9 additions & 1 deletion src/azure/cli/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def print_arguments(help_file):
for p in help_file.parameters)
last_group_name = None
for p in sorted(help_file.parameters,
key=lambda p: str(p.group_name or 'A')
key=lambda p: _get_group_priority(p.group_name)
+ str(not p.required) + p.name):
indent = 1
required_text = required_tag if p.required else ''
Expand Down Expand Up @@ -386,5 +386,13 @@ def _get_single_metadata(cmd_table):
assert len(cmd_table) == 1
return next(metadata for _, metadata in cmd_table.items())

def _get_group_priority(group_name):
priorities = {
'Resource Id Arguments': 10,
'Global Arguments': 1000,
}
key = priorities.get(group_name, 0)
return "%06d" % key

class HelpAuthoringException(Exception):
pass

0 comments on commit 5cec7c9

Please sign in to comment.