From 808c7e045d50dcb2ad512ea7fa94baf411654a95 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Wed, 13 Sep 2023 23:52:55 -0700 Subject: doc: add some recipes to the documentation --- scripts/generate.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'scripts/generate.py') diff --git a/scripts/generate.py b/scripts/generate.py index 06fbdb0..1c794ae 100755 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -3,7 +3,7 @@ import os.path import re from dataclasses import dataclass from functools import lru_cache -from typing import Dict, List +from typing import List from nvim_doc_tools import ( Vimdoc, @@ -22,6 +22,7 @@ HERE = os.path.dirname(__file__) ROOT = os.path.abspath(os.path.join(HERE, os.path.pardir)) README = os.path.join(ROOT, "README.md") DOC = os.path.join(ROOT, "doc") +RECIPES = os.path.join(DOC, "recipes.md") VIMDOC = os.path.join(DOC, "conform.txt") OPTIONS = os.path.join(ROOT, "scripts", "options_doc.lua") AUTOFORMAT = os.path.join(ROOT, "scripts", "autoformat_doc.lua") @@ -82,7 +83,7 @@ def update_autocmd_md(): example_lines.extend(f.readlines()) example_lines.extend(["```\n", "\n"]) replace_section( - README, + RECIPES, r"^$", r"^$", example_lines, @@ -117,6 +118,13 @@ def update_readme_toc(): ) +def update_recipes_toc(): + toc = ["\n"] + generate_md_toc(RECIPES) + ["\n"] + replace_section(RECIPES, r"^$", r"^$", toc) + subtoc = add_md_link_path("doc/recipes.md", toc) + replace_section(README, r"^$", r"^$", subtoc) + + def gen_options_vimdoc() -> VimdocSection: section = VimdocSection("Options", "conform-options", ["\n", ">lua\n"]) with open(OPTIONS, "r", encoding="utf-8") as f: @@ -169,5 +177,6 @@ def main() -> None: update_options() update_autocmd_md() update_md_api() + update_recipes_toc() update_readme_toc() generate_vimdoc() -- cgit v1.2.3-70-g09d2