Generate a simple man page with the output of kitty --help

This commit is contained in:
Kovid Goyal 2018-06-08 10:13:15 +05:30
parent eecf80469e
commit f88b98ccd9
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 37 additions and 70 deletions

View file

@ -9,15 +9,19 @@
import os
import re
import subprocess
import sys
from functools import partial
from docutils import nodes
from docutils.parsers.rst.roles import set_classes
from pygments.lexer import RegexLexer, bygroups
from pygments.token import Comment, Keyword, Literal, Name, String, Whitespace, Number
from pygments.token import (
Comment, Keyword, Literal, Name, Number, String, Whitespace
)
from sphinx import addnodes
from sphinx.util.logging import getLogger
from kitty.constants import str_version
# config {{{
# -- Project information -----------------------------------------------------
@ -25,11 +29,12 @@
project = 'kitty'
copyright = '2018, Kovid Goyal'
author = 'Kovid Goyal'
building_man_pages = 'man' in sys.argv
# The short X.Y version
version = ''
version = str_version
# The full version, including alpha/beta/rc tags
release = ''
release = str_version
logger = getLogger(__name__)
@ -142,47 +147,12 @@
html_show_sourcelink = False
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'kittydoc'
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'kitty.tex', 'kitty Documentation',
'Kovid Goyal', 'manual'),
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'kitty', 'kitty Documentation',
('invocation', 'kitty', 'kitty Documentation',
[author], 1)
]
@ -194,7 +164,7 @@
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'kitty', 'kitty Documentation',
author, 'kitty', 'One line description of project.',
author, 'kitty', 'A cross-platform, fast, feature full, GPU based terminal emulator',
'Miscellaneous'),
]
# }}}

View file

@ -1,25 +0,0 @@
#!/usr/bin/env python3
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import os
import subprocess
import shutil
docs_dir = os.path.dirname(os.path.abspath(__file__))
publish_dir = os.path.join(os.path.dirname(os.path.dirname(docs_dir)), 'kovidgoyal.github.io', 'kitty')
subprocess.check_call(['make', 'html'], cwd=docs_dir)
if os.path.exists(publish_dir):
shutil.rmtree(publish_dir)
shutil.copytree(os.path.join(docs_dir, '_build', 'html'), publish_dir)
shutil.copy2(os.path.join(docs_dir, 'installer.sh'), publish_dir)
installer = os.path.join(docs_dir, 'installer.py')
subprocess.check_call([
'python3', '-c', f"import runpy; runpy.run_path('{installer}', run_name='update_wrapper')",
os.path.join(publish_dir, 'installer.sh')])
os.chdir(os.path.dirname(publish_dir))
subprocess.check_call(['git', 'add', 'kitty'])
subprocess.check_call(['git', 'commit', '-m', 'kitty website updates'])
subprocess.check_call(['git', 'push'])

View file

@ -10,6 +10,7 @@
import pprint
import re
import shlex
import shutil
import subprocess
import sys
import time
@ -18,6 +19,8 @@
os.chdir(os.path.dirname(os.path.abspath(__file__)))
build_path = os.path.abspath('../build-kitty')
docs_dir = os.path.abspath('docs')
publish_dir = os.path.abspath(os.path.join('..', 'kovidgoyal.github.io', 'kitty'))
raw = open('kitty/constants.py').read()
nv = re.search(
r'^version\s+=\s+\((\d+), (\d+), (\d+)\)', raw, flags=re.MULTILINE)
@ -25,13 +28,13 @@
appname = re.search(
r"^appname\s+=\s+'([^']+)'", raw, flags=re.MULTILINE).group(1)
ALL_ACTIONS = 'build tag upload website'.split()
ALL_ACTIONS = 'man html build tag upload website'.split()
def call(*cmd):
def call(*cmd, cwd=None):
if len(cmd) == 1:
cmd = shlex.split(cmd[0])
ret = subprocess.Popen(cmd).wait()
ret = subprocess.Popen(cmd, cwd=cwd).wait()
if ret != 0:
raise SystemExit(ret)
@ -50,8 +53,27 @@ def run_tag(args):
call('git push origin v{0}'.format(version))
def run_man(args):
call('make man', cwd=docs_dir)
def run_html(args):
call('make html', cwd=docs_dir)
def run_website(args):
call('docs/publish.py')
if os.path.exists(publish_dir):
shutil.rmtree(publish_dir)
shutil.copytree(os.path.join(docs_dir, '_build', 'html'), publish_dir)
shutil.copy2(os.path.join(docs_dir, 'installer.sh'), publish_dir)
installer = os.path.join(docs_dir, 'installer.py')
subprocess.check_call([
'python3', '-c', f"import runpy; runpy.run_path('{installer}', run_name='update_wrapper')",
os.path.join(publish_dir, 'installer.sh')])
os.chdir(os.path.dirname(publish_dir))
subprocess.check_call(['git', 'add', 'kitty'])
subprocess.check_call(['git', 'commit', '-m', 'kitty website updates'])
subprocess.check_call(['git', 'push'])
class ReadFileWithProgressReporting(io.BufferedReader): # {{{
@ -296,7 +318,7 @@ def main():
'--only',
default=False,
action='store_true',
help='Only run the specified action')
help='Only run the specified action, by default the specified action and all sub-sequent actions are run')
parser.add_argument(
'action',
default='build',