From 25f833c5a6e449ce2dbf8cca6ebf95d3d17d3e3b Mon Sep 17 00:00:00 2001 From: Gil Robalo Rei Date: Fri, 17 Jan 2025 14:57:00 +0100 Subject: [PATCH] refactor(conf.py): use create_documentation_files to create rst files --- doc/source/conf.py | 4 +-- doc/source/create_documentation_files.py | 11 +++---- doc/source/create_documentation_stuff.py | 37 ------------------------ doc/source/index.rst | 8 ++--- 4 files changed, 10 insertions(+), 50 deletions(-) delete mode 100644 doc/source/create_documentation_stuff.py diff --git a/doc/source/conf.py b/doc/source/conf.py index e56eb0b7..35431805 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -33,9 +33,9 @@ # Add the readme example as easy tutorial for now sys.path.insert(1, str(relative_path_from_queens("doc/source").resolve())) -from create_documentation_stuff import create_tutorial_from_readme +from create_documentation_files import main -create_tutorial_from_readme() +main() # -- General configuration ------------------------------------------------ diff --git a/doc/source/create_documentation_files.py b/doc/source/create_documentation_files.py index 9ab3c917..041915fa 100644 --- a/doc/source/create_documentation_files.py +++ b/doc/source/create_documentation_files.py @@ -17,7 +17,8 @@ import re import sys -import pandoc +from pandoc import read as pandoc_read +from pandoc import write as pandoc_write from queens.utils.path_utils import relative_path_from_queens @@ -116,10 +117,10 @@ def create_testing(): """Create pages related to testing.""" contributing_path = relative_path_from_queens("tests/README.md") md_text = load_markdown(md_path=contributing_path) - doc = pandoc.read(md_text, format="markdown") + doc = pandoc_read(md_text, format="markdown") rst_path = "testing.rst" - pandoc.write(doc, file=relative_to_doc_source(rst_path), format="rst") + pandoc_write(doc, file=relative_to_doc_source(rst_path), format="rst") return rst_path @@ -127,10 +128,10 @@ def create_contributing(): """Create pages related to contributing.""" contributing_path = relative_path_from_queens("CONTRIBUTING.md") md_text = load_markdown(md_path=contributing_path) - doc = pandoc.read(md_text) + doc = pandoc_read(md_text) rst_path = "contributing.rst" - pandoc.write(doc, file=relative_to_doc_source(rst_path), format="rst") + pandoc_write(doc, file=relative_to_doc_source(rst_path), format="rst") return rst_path diff --git a/doc/source/create_documentation_stuff.py b/doc/source/create_documentation_stuff.py deleted file mode 100644 index d0c62e71..00000000 --- a/doc/source/create_documentation_stuff.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: LGPL-3.0-or-later -# Copyright (c) 2025, QUEENS contributors. -# -# This file is part of QUEENS. -# -# QUEENS is free software: you can redistribute it and/or modify it under the terms of the GNU -# Lesser General Public License as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. QUEENS is distributed in the hope that it will -# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You -# should have received a copy of the GNU Lesser General Public License along with QUEENS. If not, -# see . -# -import shutil -import sys - -from queens.utils.path_utils import relative_path_from_queens - - -def create_tutorial_from_readme(): - sys.path.insert(1, str(relative_path_from_queens("test_utils").resolve())) - from get_queens_example_from_readme import get_queens_example_from_readme - - example = get_queens_example_from_readme(".") - tutorial = relative_path_from_queens("doc/source/tutorials.rst") - current_tutorial_text = """.. _tutorials: - -Tutorials and examples -================================== - -Work in progress, but here a simple example from our `README.md `_: - -.. code-block:: python""" + example.replace( - "\n", "\n " - ) - tutorial.write_text(current_tutorial_text) diff --git a/doc/source/index.rst b/doc/source/index.rst index e99bb5ca..5b5ce0ee 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -1,8 +1,3 @@ -.. pqueens documentation master file, created by - sphinx-quickstart on Tue Apr 4 13:44:16 2017. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - Welcome to the QUEENS' documentation! =================================== @@ -19,7 +14,8 @@ Welcome to the QUEENS' documentation! intro architecture tutorials - modules.rst + development + Indices and tables