Convert manual from LaTeX to Markup
[gromacs.git] / admin / builds / documentation.py
blob2214e35661b915196ded772f6438db5cdf94a651
2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2015,2016,2017,2018, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 import os
36 import re
38 build_out_of_source = True
40 extra_options = {
41 'source-md5': Option.string
44 def do_build(context):
45 cmake_opts = {
46 'GMX_BUILD_HELP': 'ON',
47 'GMX_BUILD_MANUAL': 'ON',
48 'SOURCE_MD5SUM': context.opts.source_md5,
49 'CMAKE_BUILD_TYPE': 'Debug',
50 'GMX_GPU': 'OFF',
51 'GMX_OPENMP': 'OFF',
52 'GMX_SIMD': 'None',
53 'GMX_USE_RDTSCP': 'OFF'
55 release = (context.job_type == JobType.RELEASE)
56 if release:
57 cmake_opts['GMX_BUILD_TARBALL'] = 'ON'
58 elif context.job_type == JobType.GERRIT:
59 cmake_opts['GMX_COMPACT_DOXYGEN'] = 'ON'
60 cmake_opts.update(context.get_doc_cmake_options(
61 doxygen_version='1.8.5', sphinx_version='1.6.1'))
62 context.run_cmake(cmake_opts);
63 context.build_target(target='gmx', parallel=True,
64 continue_on_failure=True)
66 context.build_target(target='manual', parallel=False,
67 target_descr='PDF manual', continue_on_failure=True)
68 logfile = os.path.join(context.workspace.build_dir, 'docs/manual/gromacs.log')
69 if os.path.isfile(logfile):
70 with open(logfile, 'r') as f:
71 manual_log = f.read()
72 if re.search(r'LaTeX Warning: Reference .* on page .* undefined', manual_log):
73 context.mark_unstable('undefined references in PDF manual')
74 context.publish_logs([logfile])
76 # check-source is not necessary for a release build, and building these
77 # separately causes many of the Doxygen targets to get built twice if run
78 # from a tarball.
79 if not release:
80 context.build_target(target='doxygen-all', parallel=False,
81 target_descr='Doxygen documentation', continue_on_failure=True)
82 context.build_target(target='check-source', parallel=False,
83 failure_string='check-source failed to run', continue_on_failure=True)
84 logs = []
85 for target in ('check-source', 'doxygen-xml', 'doxygen-user',
86 'doxygen-lib', 'doxygen-full'):
87 logfile = os.path.join(context.workspace.build_dir,
88 'docs/doxygen/{0}.log'.format(target))
89 if os.path.isfile(logfile) and os.stat(logfile).st_size > 0:
90 context.mark_unstable('{0} produced warnings'.format(target))
91 logs.append(logfile)
92 context.publish_logs(logs, category='doxygen')
93 if context.failed:
94 return
96 context.build_target(target='sphinx-input', parallel=False,
97 failure_string='Generating Sphinx input failed',
98 continue_on_failure=True)
99 context.build_target(target='sphinx-programs', parallel=False,
100 failure_string='Running gmx help -export rst failed',
101 continue_on_failure=True)
102 if context.failed:
103 return
105 sphinx_targets = [ ('webpage-sphinx', 'html', 'HTML') ]
106 if not release:
107 sphinx_targets.extend((
108 ('man', 'man', 'man page'),
109 ('install-guide', 'install', 'install-guide')
111 logs = []
112 for target, log, descr in sphinx_targets:
113 context.build_target(target=target, parallel=False,
114 failure_string='Sphinx: {0} generation failed'.format(descr),
115 continue_on_failure=True)
116 logfile = os.path.join(context.workspace.build_dir,
117 'docs/sphinx-{0}.log'.format(log))
118 if os.path.isfile(logfile) and os.stat(logfile).st_size > 0:
119 context.mark_unstable('Sphinx: {0} generation produced warnings'.format(descr))
120 logs.append(logfile)
121 context.publish_logs(logs, category='sphinx')
122 if context.failed:
123 return
125 context.build_target(target='webpage', parallel=False)
126 if context.failed:
127 return
129 ignore_urls = ['html-full', 'html-user', 'html-lib', '.tar.gz', '_sources']
130 cmd = ['linkchecker', 'docs/html/index.html', '-f',
131 context.workspace.get_project_dir(Project.GROMACS) + '/docs/linkcheckerrc',
132 '-Fxml']
133 for url in ignore_urls:
134 cmd.extend(['--ignore-url', url])
136 context.run_cmd(cmd, ignore_failure=False)
138 logfile = os.path.join(context.workspace.build_dir,
139 'docs/linkchecker-out.xml')
140 if os.path.isfile(logfile):
141 with open(logfile, 'r') as f:
142 manual_log = f.read()
143 if re.search(r'URLError:', manual_log):
144 context.mark_unstable('non resolvable URL in webpage')
145 if re.search(r'warnings', manual_log):
146 context.mark_unstable('empty pages in web documentation')
147 context.publish_logs([logfile], category='webpage')
149 if context.failed:
150 return
152 if release:
153 version_info = context.read_cmake_variable_file('VersionInfo.cmake')
154 version = version_info['GMX_VERSION_STRING']
155 package_name = 'website-' + version
156 context.make_archive(package_name, root_dir='docs/html', prefix=package_name)