From f88b98ccd9b2870cc25601648adc66b6292976de Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 8 Jun 2018 10:13:15 +0530 Subject: [PATCH] Generate a simple man page with the output of kitty --help --- docs/conf.py | 50 ++++++++++--------------------------------------- docs/publish.py | 25 ------------------------- publish.py | 32 ++++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 70 deletions(-) delete mode 100755 docs/publish.py diff --git a/docs/conf.py b/docs/conf.py index 4bb2766c4..089653884 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 @@ from sphinx.util.logging import getLogger 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_sidebars = { 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 @@ man_pages = [ # 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'), ] # }}} diff --git a/docs/publish.py b/docs/publish.py deleted file mode 100755 index 57618b6d6..000000000 --- a/docs/publish.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -# vim:fileencoding=utf-8 -# License: GPL v3 Copyright: 2018, Kovid Goyal - - -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']) diff --git a/publish.py b/publish.py index ab4a09d76..d4debeeeb 100755 --- a/publish.py +++ b/publish.py @@ -10,6 +10,7 @@ import os import pprint import re import shlex +import shutil import subprocess import sys import time @@ -18,6 +19,8 @@ import requests 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 @@ version = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3)) 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',