Merge lp:~javier.collado/utah/docs_html_build_errors into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 714
Merged at revision: 714
Proposed branch: lp:~javier.collado/utah/docs_html_build_errors
Merge into: lp:utah
Diff against target: 146 lines (+67/-69)
1 file modified
docs/source/conf.py (+67/-69)
To merge this branch: bzr merge lp:~javier.collado/utah/docs_html_build_errors
Reviewer Review Type Date Requested Status
UTAH Dev Pending
Review via email: mp+130380@code.launchpad.net

Description of the change

The configuration file `conf.py` tries to generate the contents for the man
pages only when they are going to be built. However, it seems that trying to
generate the html documentation without those files results in lots errors
being printed. To fix that, the files for the man pages are generated for all
cases.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

So is the change here just removing these lines:
# Note: This assumes that sphinx-build is called as in the makefile like this:
# /usr/bin/sphinx-build -b man <sphinx_opts>
if sys.argv[2] == 'man':
Adding the extra blank line, and unindenting everything? If so, that makes sense to me.

Revision history for this message
Javier Collado (javier.collado) wrote :

@Max

Yes, that's the only thing it does.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'docs/source/conf.py'
--- docs/source/conf.py 2012-09-14 11:11:38 +0000
+++ docs/source/conf.py 2012-10-18 15:17:19 +0000
@@ -67,76 +67,74 @@
67 'apt', 'apt.cache'):67 'apt', 'apt.cache'):
68 sys.modules[mod_name] = ModuleMock(mod_name)68 sys.modules[mod_name] = ModuleMock(mod_name)
6969
70
70# Autogenerate help contents for manual pages when building manual pages71# Autogenerate help contents for manual pages when building manual pages
71# Note: This assumes that sphinx-build is called as in the makefile like this:72def get_parser_strings(script_name, parser):
72# /usr/bin/sphinx-build -b man <sphinx_opts>73 description = parser.description
73if sys.argv[2] == 'man':74
74 def get_parser_strings(script_name, parser):75 help_lines = parser.format_help().splitlines()
75 description = parser.description76 options_lines = itertools.dropwhile(
7677 lambda l: l != 'optional arguments:',
77 help_lines = parser.format_help().splitlines()78 help_lines) # Drop usage
78 options_lines = itertools.dropwhile(79 options_lines = itertools.takewhile(
79 lambda l: l != 'optional arguments:',80 lambda l: bool(l),
80 help_lines) # Drop usage81 options_lines) # Drop epilog
81 options_lines = itertools.takewhile(82 options_lines.next() # Drop first line
82 lambda l: bool(l),83
83 options_lines) # Drop epilog84 def fix_line(line):
84 options_lines.next() # Drop first line85 """
8586 Remove indentation and replace curly braces with angle brackets
86 def fix_line(line):87 to match the expected format
87 """88 """
88 Remove indentation and replace curly braces with angle brackets89 line = line[2:]
89 to match the expected format90
90 """91 # Apply changes only to option lines,
91 line = line[2:]92 # not the ones with the help text
9293 if line.startswith('-'):
93 # Apply changes only to option lines,94 line = line.replace('{', '<')
94 # not the ones with the help text95 line = line.replace('}', '>')
95 if line.startswith('-'):96 return line
96 line = line.replace('{', '<')97
97 line = line.replace('}', '>')98 options_lines = [fix_line(line) for line in options_lines]
98 return line99 options = '\n'.join(options_lines)
99100
100 options_lines = [fix_line(line) for line in options_lines]101 if parser.epilog is None:
101 options = '\n'.join(options_lines)102 epilog = ''
102103 else:
103 if parser.epilog is None:104 # Highlight program name and options
104 epilog = ''105 epilog = parser.epilog % {'prog': '**%s**' % script_name}
105 else:106 epilog = re.sub(r'(-\w)', r'**\1**', epilog)
106 # Highlight program name and options107
107 epilog = parser.epilog % {'prog': '**%s**' % script_name}108 # Duplicate backslashes to avoid dropping them
108 epilog = re.sub(r'(-\w)', r'**\1**', epilog)109 # because of the rst formatting
109110 epilog = re.sub(r'\\', r'\\\\', epilog)
110 # Duplicate backslashes to avoid dropping them111
111 # because of the rst formatting112 # Drop 'For example:'
112 epilog = re.sub(r'\\', r'\\\\', epilog)113 epilog = '\n'.join(epilog.splitlines()[1:])
113114
114 # Drop 'For example:'115 # Use line blocks to preserve line breaks
115 epilog = '\n'.join(epilog.splitlines()[1:])116 # Make sure that block is in a separate paragraph
116117 epilog = re.sub(r'^\t', '\n| ', epilog, flags=re.M, count=1)
117 # Use line blocks to preserve line breaks118 epilog = re.sub(r'^\t', '| ', epilog, flags=re.M)
118 # Make sure that block is in a separate paragraph119
119 epilog = re.sub(r'^\t', '\n| ', epilog, flags=re.M, count=1)120 return description, options, epilog
120 epilog = re.sub(r'^\t', '| ', epilog, flags=re.M)121
121122module_names = ('client', 'run_install_test', 'run_test_cobbler',
122 return description, options, epilog123 'run_test_vm', 'run_utah_tests')
123124for module_name in module_names:
124 module_names = ('client', 'run_install_test', 'run_test_cobbler',125 module = __import__(module_name)
125 'run_test_vm', 'run_utah_tests')126 parser = module.get_parser()
126 for module_name in module_names:127 if module_name == 'client':
127 module = __import__(module_name)128 script_name = 'utah'
128 parser = module.get_parser()129 else:
129 if module_name == 'client':130 script_name = '{}.py'.format(module_name)
130 script_name = 'utah'131 description, options, epilog = get_parser_strings(script_name, parser)
131 else:132
132 script_name = '{}.py'.format(module_name)133 for section_name in ('description', 'options', 'epilog'):
133 description, options, epilog = get_parser_strings(script_name, parser)134 section = locals()[section_name]
134135 filename = 'man/{}_{}.txt'.format(module_name, section_name)
135 for section_name in ('description', 'options', 'epilog'):136 with open(filename, 'w') as f:
136 section = locals()[section_name]137 f.write(section)
137 filename = 'man/{}_{}.txt'.format(module_name, section_name)
138 with open(filename, 'w') as f:
139 f.write(section)
140138
141# -- General configuration ----------------------------------------------------139# -- General configuration ----------------------------------------------------
142140

Subscribers

People subscribed via source and target branches