From 7b1449ba469fba0af6adf9282007b65aabe8bce6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Jun 2018 13:57:51 +0530 Subject: [PATCH] Include sample conf files --- docs/conf.py | 29 +++++++++++++++++++++-------- docs/conf.rst | 8 ++++++++ docs/kittens/diff.rst | 8 ++++++++ kitty/config_data.py | 2 +- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f682c899a..4bb2766c4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -70,8 +70,10 @@ language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path . -exclude_patterns = ['_build', 'Thumbs.db', - '.DS_Store', 'generated/cli-*', 'generated/conf-*'] +exclude_patterns = [ + '_build', 'Thumbs.db', '.DS_Store', + 'generated/cli-*.rst', 'generated/conf-*.rst' +] # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' @@ -300,6 +302,8 @@ class ConfLexer(RegexLexer): tokens = { 'root': [ (r'#.*?$', Comment.Single), + (r'\s+$', Whitespace), + (r'\s+', Whitespace), (r'(include)(\s+)(.+?)$', bygroups(Comment.Preproc, Whitespace, Name.Namespace)), (r'(map)(\s+)(\S+)(\s+)', bygroups( Keyword.Declaration, Whitespace, String, Whitespace), 'action'), @@ -522,18 +526,27 @@ def write_conf_docs(app, all_kitten_names): sc_role.warn_dangling = True sc_role.process_link = process_shortcut_link + def generate(all_options, name='kitty'): + from kitty.conf.definition import as_conf_file + from textwrap import indent + with open(f'generated/conf-{name}.rst', 'w', encoding='utf-8') as f: + print('.. highlight:: conf\n', file=f) + f.write(render_conf(name, all_options.values())) + + with open(f'generated/conf-{name}-literal.rst', 'w', encoding='utf-8') as f: + print('.. code-block:: conf\n', file=f) + text = '\n'.join(as_conf_file(all_options.values())) + text = indent(text, ' ', lambda l: True) + print(text, file=f) + from kitty.config_data import all_options - with open('generated/conf-kitty.rst', 'w', encoding='utf-8') as f: - print('.. highlight:: conf\n', file=f) - f.write(render_conf('kitty', all_options.values())) + generate(all_options) from kittens.runner import get_kitten_conf_docs for kitten in all_kitten_names: all_options = get_kitten_conf_docs(kitten) if all_options: - with open(f'generated/conf-kitten-{kitten}.rst', 'w', encoding='utf-8') as f: - print('.. highlight:: conf\n', file=f) - f.write(render_conf(kitten, all_options.values())) + generate(all_options, f'kitten-{kitten}') # }}} diff --git a/docs/conf.rst b/docs/conf.rst index bd1f21e3f..dc3ee44a7 100644 --- a/docs/conf.rst +++ b/docs/conf.rst @@ -30,3 +30,11 @@ expanded, so :code:`${USER}.conf` becomes :file:`name.conf` if .. include:: /generated/conf-kitty.rst + + +Sample kitty.conf +^^^^^^^^^^^^^^^^^^^^^ + +Below is a sample :file:`kitty.conf` with all default settings. + +.. include:: /generated/conf-kitty-literal.rst diff --git a/docs/kittens/diff.rst b/docs/kittens/diff.rst index 2800752ed..0674460b1 100644 --- a/docs/kittens/diff.rst +++ b/docs/kittens/diff.rst @@ -140,3 +140,11 @@ of code needed (the entire implementation is under 2000 lines of code). And fundamentally, it's kitty only because I wrote it for myself, and I am highly unlikely to use any other terminals :) + + +Sample diff.conf +----------------- + +Below is a sample :file:`diff.conf` with all default settings. + +.. include:: /generated/conf-kitten-diff-literal.rst diff --git a/kitty/config_data.py b/kitty/config_data.py index 2ed8f38d5..ec8ce1023 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -636,7 +636,7 @@ probably better off just hiding the titlebar with :opt:`macos_hide_titlebar`. ''')) o('macos_hide_titlebar', False, long_text=_(''' -# Hide the kitty window's title bar on macOS.''')) +Hide the kitty window's title bar on macOS.''')) o('macos_option_as_alt', True, long_text=_(''' Use the option key as an alt key. With this set to no, kitty will use