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
1=== modified file 'docs/source/conf.py'
2--- docs/source/conf.py 2012-09-14 11:11:38 +0000
3+++ docs/source/conf.py 2012-10-18 15:17:19 +0000
4@@ -67,76 +67,74 @@
5 'apt', 'apt.cache'):
6 sys.modules[mod_name] = ModuleMock(mod_name)
7
8+
9 # Autogenerate help contents for manual pages when building manual pages
10-# Note: This assumes that sphinx-build is called as in the makefile like this:
11-# /usr/bin/sphinx-build -b man <sphinx_opts>
12-if sys.argv[2] == 'man':
13- def get_parser_strings(script_name, parser):
14- description = parser.description
15-
16- help_lines = parser.format_help().splitlines()
17- options_lines = itertools.dropwhile(
18- lambda l: l != 'optional arguments:',
19- help_lines) # Drop usage
20- options_lines = itertools.takewhile(
21- lambda l: bool(l),
22- options_lines) # Drop epilog
23- options_lines.next() # Drop first line
24-
25- def fix_line(line):
26- """
27- Remove indentation and replace curly braces with angle brackets
28- to match the expected format
29- """
30- line = line[2:]
31-
32- # Apply changes only to option lines,
33- # not the ones with the help text
34- if line.startswith('-'):
35- line = line.replace('{', '<')
36- line = line.replace('}', '>')
37- return line
38-
39- options_lines = [fix_line(line) for line in options_lines]
40- options = '\n'.join(options_lines)
41-
42- if parser.epilog is None:
43- epilog = ''
44- else:
45- # Highlight program name and options
46- epilog = parser.epilog % {'prog': '**%s**' % script_name}
47- epilog = re.sub(r'(-\w)', r'**\1**', epilog)
48-
49- # Duplicate backslashes to avoid dropping them
50- # because of the rst formatting
51- epilog = re.sub(r'\\', r'\\\\', epilog)
52-
53- # Drop 'For example:'
54- epilog = '\n'.join(epilog.splitlines()[1:])
55-
56- # Use line blocks to preserve line breaks
57- # Make sure that block is in a separate paragraph
58- epilog = re.sub(r'^\t', '\n| ', epilog, flags=re.M, count=1)
59- epilog = re.sub(r'^\t', '| ', epilog, flags=re.M)
60-
61- return description, options, epilog
62-
63- module_names = ('client', 'run_install_test', 'run_test_cobbler',
64- 'run_test_vm', 'run_utah_tests')
65- for module_name in module_names:
66- module = __import__(module_name)
67- parser = module.get_parser()
68- if module_name == 'client':
69- script_name = 'utah'
70- else:
71- script_name = '{}.py'.format(module_name)
72- description, options, epilog = get_parser_strings(script_name, parser)
73-
74- for section_name in ('description', 'options', 'epilog'):
75- section = locals()[section_name]
76- filename = 'man/{}_{}.txt'.format(module_name, section_name)
77- with open(filename, 'w') as f:
78- f.write(section)
79+def get_parser_strings(script_name, parser):
80+ description = parser.description
81+
82+ help_lines = parser.format_help().splitlines()
83+ options_lines = itertools.dropwhile(
84+ lambda l: l != 'optional arguments:',
85+ help_lines) # Drop usage
86+ options_lines = itertools.takewhile(
87+ lambda l: bool(l),
88+ options_lines) # Drop epilog
89+ options_lines.next() # Drop first line
90+
91+ def fix_line(line):
92+ """
93+ Remove indentation and replace curly braces with angle brackets
94+ to match the expected format
95+ """
96+ line = line[2:]
97+
98+ # Apply changes only to option lines,
99+ # not the ones with the help text
100+ if line.startswith('-'):
101+ line = line.replace('{', '<')
102+ line = line.replace('}', '>')
103+ return line
104+
105+ options_lines = [fix_line(line) for line in options_lines]
106+ options = '\n'.join(options_lines)
107+
108+ if parser.epilog is None:
109+ epilog = ''
110+ else:
111+ # Highlight program name and options
112+ epilog = parser.epilog % {'prog': '**%s**' % script_name}
113+ epilog = re.sub(r'(-\w)', r'**\1**', epilog)
114+
115+ # Duplicate backslashes to avoid dropping them
116+ # because of the rst formatting
117+ epilog = re.sub(r'\\', r'\\\\', epilog)
118+
119+ # Drop 'For example:'
120+ epilog = '\n'.join(epilog.splitlines()[1:])
121+
122+ # Use line blocks to preserve line breaks
123+ # Make sure that block is in a separate paragraph
124+ epilog = re.sub(r'^\t', '\n| ', epilog, flags=re.M, count=1)
125+ epilog = re.sub(r'^\t', '| ', epilog, flags=re.M)
126+
127+ return description, options, epilog
128+
129+module_names = ('client', 'run_install_test', 'run_test_cobbler',
130+ 'run_test_vm', 'run_utah_tests')
131+for module_name in module_names:
132+ module = __import__(module_name)
133+ parser = module.get_parser()
134+ if module_name == 'client':
135+ script_name = 'utah'
136+ else:
137+ script_name = '{}.py'.format(module_name)
138+ description, options, epilog = get_parser_strings(script_name, parser)
139+
140+ for section_name in ('description', 'options', 'epilog'):
141+ section = locals()[section_name]
142+ filename = 'man/{}_{}.txt'.format(module_name, section_name)
143+ with open(filename, 'w') as f:
144+ f.write(section)
145
146 # -- General configuration ----------------------------------------------------
147

Subscribers

People subscribed via source and target branches