Start with manpage generation

This commit is contained in:
Florian Bruhin 2014-07-18 07:48:33 +02:00
parent 8dbbcf48be
commit d4c3a65fe3
4 changed files with 42 additions and 17 deletions

View File

@ -17,7 +17,9 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""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 import os.path
@ -28,5 +30,6 @@ __maintainer__ = __author__
__email__ = "mail@qutebrowser.org" __email__ = "mail@qutebrowser.org"
__version_info__ = (0, 0, 0) __version_info__ = (0, 0, 0)
__version__ = '.'.join(map(str, __version_info__)) __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__)) basedir = os.path.dirname(os.path.realpath(__file__))

View File

@ -20,18 +20,16 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import qutebrowser
from qutebrowser.utils.checkpyver import check_python_version from qutebrowser.utils.checkpyver import check_python_version
check_python_version() check_python_version()
import qutebrowser.utils.earlyinit as earlyinit import qutebrowser.utils.earlyinit as earlyinit
def _parse_args(): def get_argparser():
"""Parse command line options. """Get the argparse parser."""
parser = ArgumentParser("usage: qutebrowser",
Return: description=qutebrowser.__description__)
Argument namespace from argparse.
"""
parser = ArgumentParser("usage: %(prog)s [options]")
parser.add_argument('-c', '--confdir', help="Set config directory (empty " parser.add_argument('-c', '--confdir', help="Set config directory (empty "
"for no config storage)") "for no config storage)")
parser.add_argument('-V', '--version', help="Show version and quit.", parser.add_argument('-V', '--version', help="Show version and quit.",
@ -75,13 +73,14 @@ def _parse_args():
"startup.", metavar=':command') "startup.", metavar=':command')
# URLs will actually be in command # URLs will actually be in command
parser.add_argument('url', nargs='*', help="URLs to open on startup.") parser.add_argument('url', nargs='*', help="URLs to open on startup.")
return parser.parse_args() return parser
def main(): def main():
"""Main entry point for qutebrowser.""" """Main entry point for qutebrowser."""
earlyinit.init_faulthandler() earlyinit.init_faulthandler()
args = _parse_args() parser = get_argparser()
args = parser.parse_args()
earlyinit.check_pyqt_core() earlyinit.check_pyqt_core()
# We do this import late as we need to do the version checking first. # 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. # Note we may not import webkit stuff yet as fix_harfbuzz didn't run.

View File

@ -28,6 +28,7 @@ from tempfile import mkstemp
sys.path.insert(0, os.getcwd()) sys.path.insert(0, os.getcwd())
import qutebrowser
# We import qutebrowser.app so all @cmdutils-register decorators are run. # We import qutebrowser.app so all @cmdutils-register decorators are run.
import qutebrowser.app # pylint: disable=unused-import import qutebrowser.app # pylint: disable=unused-import
import qutebrowser.commands.utils as cmdutils import qutebrowser.commands.utils as cmdutils
@ -183,12 +184,33 @@ def _get_command_doc(name, cmd):
return '\n'.join(output) return '\n'.join(output)
def generate_header(f): def generate_manpage_header(f):
"""Generate an asciidoc header.""" """Generate an asciidoc header for the manpage."""
f.write('= qutebrowser manpage\n') f.write('= qutebrowser(1)\n')
f.write('Florian Bruhin <mail@qutebrowser.org>\n') f.write('Florian Bruhin <mail@qutebrowser.org>\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(':toc:\n')
f.write(':homepage: http://www.qutebrowser.org/\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): def generate_commands(f):
@ -291,8 +313,10 @@ def regenerate_authors(filename):
if __name__ == '__main__': if __name__ == '__main__':
with _open_file('doc/qutebrowser.asciidoc') as fobj: with _open_file('doc/qutebrowser.1.asciidoc') as fobj:
generate_header(fobj) generate_manpage_header(fobj)
generate_manpage_name(fobj)
generate_manpage_synopsis(fobj)
generate_settings(fobj) generate_settings(fobj)
generate_commands(fobj) generate_commands(fobj)
regenerate_authors('README.asciidoc') regenerate_authors('README.asciidoc')

View File

@ -92,8 +92,7 @@ def write_git_file():
setupdata = { setupdata = {
'name': 'qutebrowser', 'name': 'qutebrowser',
'version': '.'.join(map(str, _get_constant('version_info'))), 'version': '.'.join(map(str, _get_constant('version_info'))),
'description': ("A keyboard-driven, vim-like browser based on PyQt5 and " 'description': _get_constant('description'),
"QtWebKit."),
'long_description': read_file('README.asciidoc'), 'long_description': read_file('README.asciidoc'),
'url': 'http://www.qutebrowser.org/', 'url': 'http://www.qutebrowser.org/',
'requires': ['rfc6266'], 'requires': ['rfc6266'],