Skip to content

Commit

Permalink
Merge pull request #8304 from kyleknap/fix-line-lengths-v1
Browse files Browse the repository at this point in the history
Extend docutils line length limit
  • Loading branch information
kyleknap authored Nov 6, 2023
2 parents 7a49dbc + 9b3b86c commit 567a85c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-help-587.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "``help``",
"description": "Relax line length limit for rendered ``help`` pages"
}
21 changes: 18 additions & 3 deletions awscli/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def __init__(self, output_stream=sys.stdout):
self.output_stream = output_stream

PAGER = None
_DEFAULT_DOCUTILS_SETTINGS_OVERRIDES = {
# The default for line length limit in docutils is 10,000. However,
# currently in the documentation, it inlines all possible enums in
# the JSON syntax which exceeds this limit for some EC2 commands
# and prevents the manpages from being generated.
# This is a temporary fix to allow the manpages for these commands
# to be rendered. Long term, we should avoid enumerating over all
# enums inline for the JSON syntax snippets.
'line_length_limit': 50_000
}

def get_pager_cmdline(self):
pager = self.PAGER
Expand Down Expand Up @@ -105,7 +115,10 @@ class PosixHelpRenderer(PagingHelpRenderer):
PAGER = 'less -R'

def _convert_doc_content(self, contents):
man_contents = publish_string(contents, writer=manpage.Writer())
man_contents = publish_string(
contents, writer=manpage.Writer(),
settings_overrides=self._DEFAULT_DOCUTILS_SETTINGS_OVERRIDES,
)
if self._exists_on_path('groff'):
cmdline = ['groff', '-m', 'man', '-T', 'ascii']
elif self._exists_on_path('mandoc'):
Expand Down Expand Up @@ -154,8 +167,10 @@ class WindowsHelpRenderer(PagingHelpRenderer):
PAGER = 'more'

def _convert_doc_content(self, contents):
text_output = publish_string(contents,
writer=TextWriter())
text_output = publish_string(
contents, writer=TextWriter(),
settings_overrides=self._DEFAULT_DOCUTILS_SETTINGS_OVERRIDES,
)
return text_output

def _popen(self, *args, **kwargs):
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/docs/test_help_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from awscli.testutils import BaseAWSHelpOutputTest
from awscli.testutils import FileCreator
from awscli.testutils import mock
from awscli.testutils import aws

from awscli.compat import six
from awscli.alias import AliasLoader
Expand Down Expand Up @@ -482,3 +483,11 @@ def test_service_help_command_has_note(self):
self.driver.main(['s3api', 'get-object', 'help'])
self.assert_not_contains('outfile <value>')
self.assert_contains('<outfile>')


# Use this test class for "help" cases that require the default renderer
# (i.e. renderer from get_render()) instead of a mocked version.
class TestHelpOutputDefaultRenderer:
def test_line_lengths_do_not_break_create_launch_template_version_cmd(self):
result = aws('ec2 create-launch-template-version help')
assert 'exceeds the line-length-limit' not in result.stderr

0 comments on commit 567a85c

Please sign in to comment.