diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index b1ed9967a..59bd0da87 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -17,7 +17,9 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""A vim like browser based on Qt.""" +# pylint: disable=line-too-long + +"""A keyboard-driven, vim-like browser based on PyQt5 and QtWebKit.""" import os.path @@ -28,5 +30,6 @@ __maintainer__ = __author__ __email__ = "mail@qutebrowser.org" __version_info__ = (0, 0, 0) __version__ = '.'.join(map(str, __version_info__)) +__description__ = "A keyboard-driven, vim-like browser based on PyQt5 and QtWebKit." basedir = os.path.dirname(os.path.realpath(__file__)) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 80d58d966..7c62acbc6 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -20,18 +20,16 @@ from argparse import ArgumentParser +import qutebrowser from qutebrowser.utils.checkpyver import check_python_version check_python_version() import qutebrowser.utils.earlyinit as earlyinit -def _parse_args(): - """Parse command line options. - - Return: - Argument namespace from argparse. - """ - parser = ArgumentParser("usage: %(prog)s [options]") +def get_argparser(): + """Get the argparse parser.""" + parser = ArgumentParser("usage: qutebrowser", + description=qutebrowser.__description__) parser.add_argument('-c', '--confdir', help="Set config directory (empty " "for no config storage)") parser.add_argument('-V', '--version', help="Show version and quit.", @@ -75,13 +73,14 @@ def _parse_args(): "startup.", metavar=':command') # URLs will actually be in command parser.add_argument('url', nargs='*', help="URLs to open on startup.") - return parser.parse_args() + return parser def main(): """Main entry point for qutebrowser.""" earlyinit.init_faulthandler() - args = _parse_args() + parser = get_argparser() + args = parser.parse_args() earlyinit.check_pyqt_core() # We do this import late as we need to do the version checking first. # Note we may not import webkit stuff yet as fix_harfbuzz didn't run. diff --git a/scripts/generate_doc.py b/scripts/generate_doc.py index f097a432b..35e7ef8e0 100644 --- a/scripts/generate_doc.py +++ b/scripts/generate_doc.py @@ -28,6 +28,7 @@ from tempfile import mkstemp sys.path.insert(0, os.getcwd()) +import qutebrowser # We import qutebrowser.app so all @cmdutils-register decorators are run. import qutebrowser.app # pylint: disable=unused-import import qutebrowser.commands.utils as cmdutils @@ -183,12 +184,33 @@ def _get_command_doc(name, cmd): return '\n'.join(output) -def generate_header(f): - """Generate an asciidoc header.""" - f.write('= qutebrowser manpage\n') +def generate_manpage_header(f): + """Generate an asciidoc header for the manpage.""" + f.write('= qutebrowser(1)\n') f.write('Florian Bruhin \n') + f.write(':doctype: manpage\n') + f.write(':man source: qutebrowser\n') + f.write(':man manual: qutebrowser manpage\n') f.write(':toc:\n') f.write(':homepage: http://www.qutebrowser.org/\n') + f.write('\n') + + +def generate_manpage_name(f): + """Generate the NAME-section of the manpage.""" + f.write('== NAME\n') + f.write('qutebrowser - {}\n'.format(qutebrowser.__description__)) + f.write('\n') + + +def generate_manpage_synopsis(f): + """Generate the SYNOPSIS-section of the manpage from an argparse parser. + + TODO. + """ + f.write('== SYNOPSIS\n') + f.write('FIXME\n') + f.write('\n') def generate_commands(f): @@ -291,8 +313,10 @@ def regenerate_authors(filename): if __name__ == '__main__': - with _open_file('doc/qutebrowser.asciidoc') as fobj: - generate_header(fobj) + with _open_file('doc/qutebrowser.1.asciidoc') as fobj: + generate_manpage_header(fobj) + generate_manpage_name(fobj) + generate_manpage_synopsis(fobj) generate_settings(fobj) generate_commands(fobj) regenerate_authors('README.asciidoc') diff --git a/scripts/setupcommon.py b/scripts/setupcommon.py index 7ba06d11f..bb86c4d91 100644 --- a/scripts/setupcommon.py +++ b/scripts/setupcommon.py @@ -92,8 +92,7 @@ def write_git_file(): setupdata = { 'name': 'qutebrowser', 'version': '.'.join(map(str, _get_constant('version_info'))), - 'description': ("A keyboard-driven, vim-like browser based on PyQt5 and " - "QtWebKit."), + 'description': _get_constant('description'), 'long_description': read_file('README.asciidoc'), 'url': 'http://www.qutebrowser.org/', 'requires': ['rfc6266'],