From 0b14a4f2e04d5284b6e691ca986ab3bf3a6cb171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Bary=C5=82a?= Date: Thu, 11 Jan 2024 01:36:23 +0100 Subject: [PATCH] Docs: Remove build_book.py script and it's mentions This script is no longer necessary and just double the work --- .github/workflows/book.yml | 2 -- CONTRIBUTING.md | 7 +--- Makefile | 2 +- docs/build_book.py | 66 -------------------------------------- 4 files changed, 2 insertions(+), 75 deletions(-) delete mode 100755 docs/build_book.py diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index d476929923..7fed7200e4 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -33,7 +33,5 @@ jobs: run: cargo build --verbose --examples - name: Build the book run: mdbook build docs - - name: Build the book using the script - run: python3 docs/build_book.py - name: Run book tests run: mdbook test -L target/debug/deps docs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd2debba32..21c90ee330 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,17 +72,12 @@ But they are removed when building the book cargo install mdbook ``` -Build the book (simple method, contains `Sphinx` artifacts): +Build the book. Build output won't containt Sphinx artifacts: ```bash mdbook build docs # HTML will be in docs/book ``` -To build the release version use a script which automatically removes `Sphinx` chunks: -```bash -python3 docs/build_book.py -# HTML will be in docs/book/scriptbuild/book -``` Or serve it on a local http server (automatically refreshes on changes) ```bash diff --git a/Makefile b/Makefile index 72396cd0a7..e09ee6bc60 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ build: .PHONY: docs docs: - ./docs/build_book.py + mdbook build docs .PHONY: up up: diff --git a/docs/build_book.py b/docs/build_book.py deleted file mode 100755 index 726f33a8d3..0000000000 --- a/docs/build_book.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -# A script which removes sphinx markdown and builds the documentation book -# It copies all files to working directory, modifies the .md files -# to remove all ```eval_rst parts and builds the book -# The generated HTML will be in docs/book/scriptbuild/book - -import os -import shutil -import pathlib - -def remove_sphinx_markdown(md_file_text): - text_split = md_file_text.split("```eval_rst") - - result = text_split[0] - - for i in range(1, len(text_split)): - cur_chunk = text_split[i] - result += cur_chunk[cur_chunk.find("```") + 3:] - - return result - -# Working directory, normally book builds in docs/book -# so we can make our a folder in this build directory -work_dir = os.path.join("docs", "book", "scriptbuild") -os.makedirs(work_dir, exist_ok = True) - -# All modified sources will be put in work_dir/source -src_dir = os.path.join(work_dir, "source") -os.makedirs(src_dir, exist_ok = True) - -# Generated HTML will be put in work_dir/book -build_dir = os.path.join(work_dir, "book") - - - -# Copy all mdbook files to work_dir before modifying - -# Copy book.toml -shutil.copyfile(os.path.join("docs", "book.toml"), os.path.join(work_dir, "book.toml")) - -# Go over all .md files, remove the ``` sphinx parts and put them in work_dir/source -for mdfile_path in pathlib.Path(os.path.join("docs", "source")).rglob("*.md"): - - # Path in the book structure ex. queries/queries.md instead of docs/source/queries/queries.md - relative_path = mdfile_path.relative_to(os.path.join("docs", "source")) - - # Read the current file - mdfile = open(mdfile_path, "r").read() - - # Remove sphinx markdown - new_mdfile = remove_sphinx_markdown(mdfile) - - # Write the modified file to src_dir - new_mdfile_path = os.path.join(src_dir, relative_path) - os.makedirs(os.path.dirname(new_mdfile_path), exist_ok = True) - open(new_mdfile_path, "w").write(new_mdfile) - -build_result = os.system(f"mdbook build {work_dir}") - -if build_result == 0: - print(f"OK Done - rendered HTML is in {build_dir}") - exit(0) -else: - print(f"ERROR: mdbook build returned: {build_result}") - exit(1)