From af8f0edfc8351a972f4552c942954aef3beb0d9c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 25 May 2023 19:07:41 +0200 Subject: [PATCH] Fix some unecessary Sphinx warnings in RST preview --- sphinx/sphinx_to_html.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sphinx/sphinx_to_html.py b/sphinx/sphinx_to_html.py index f293a7e..f7b1c49 100755 --- a/sphinx/sphinx_to_html.py +++ b/sphinx/sphinx_to_html.py @@ -70,10 +70,10 @@ with tempfile.TemporaryDirectory() as tmp_dir: return f"image:: {image_url}/{matchobj.group(1).strip('/')}" page_contents = re.sub(":doc:`/(.+?)`", doc_link, page_contents) - page_contents = re.sub(":doc:`(.+?)<(.+?)>`", doc_label_link, page_contents) - page_contents = re.sub(":ref:`(.+?)<(.+?)>`", ref_label_link, page_contents) + page_contents = re.sub(":doc:`([\w\s\n-]+?)\n?<(.+?)>`", doc_label_link, page_contents) + page_contents = re.sub(":ref:`([\w\s\n-]+?)\n?<(.+?)>`", ref_label_link, page_contents) page_contents = re.sub(":ref:`([\w\s-]+?)`", ref_link, page_contents) - page_contents = re.sub(":term:`(.+?)<(.+?)>`", term_link, page_contents) + page_contents = re.sub(":term:`([\w\s\n-]+?)\n?<(.+?)>`", term_link, page_contents) page_contents = re.sub(":term:`([\w\s-]+?)`", term_link, page_contents) page_contents = re.sub("figure:: (.+?)", figure_link, page_contents) page_contents = re.sub("image:: (.+?)", image_link, page_contents) @@ -87,6 +87,9 @@ with tempfile.TemporaryDirectory() as tmp_dir: page_contents = re.sub("literalinclude::(.*)", include_directive, page_contents) page_contents = re.sub("include::(.*)", include_directive, page_contents) page_contents = re.sub("raw::(.*)", raw_directive, page_contents) + page_contents = re.sub(".. toctree::(.*)", ".. code-block:: none", page_contents) + page_contents = re.sub(":maxdepth:(.*)", "", page_contents) + page_contents = page_contents.replace("|BLENDER_VERSION|", "BLENDER_VERSION") page_filepath.write_text(page_contents)