public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH (pushed)] doc: Modernize baseconf.py.
@ 2022-11-10  5:33 Martin Liška
  0 siblings, 0 replies; only message in thread
From: Martin Liška @ 2022-11-10  5:33 UTC (permalink / raw)
  To: gcc-patches

Pushed.

ChangeLog:

	* doc/baseconf.py: Modernize by using pathlib.
---
 doc/baseconf.py | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/doc/baseconf.py b/doc/baseconf.py
index d85659e4540..8021a101e77 100644
--- a/doc/baseconf.py
+++ b/doc/baseconf.py
@@ -11,29 +11,31 @@
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #
 import os
-import time
 import sys
+import time
+from pathlib import Path
 
-# gccint needs a deeper stack limit
-sys.setrecursionlimit(2000)
+# Build paths and add path to gcc_sphinx.py extension.
+folder = Path(__file__).resolve().parent
+doc_modules = folder / 'modules'
+gcc_srcdir = folder / '..' / 'gcc'
 
-# -- Project information -----------------------------------------------------
+sys.path.insert(0, str(doc_modules))
 
-# The full version, including alpha/beta/rc tags
+# gccint needs a deeper stack limit.
+sys.setrecursionlimit(2000)
 
-folder = os.path.dirname(os.path.realpath(__file__))
-doc_modules = os.path.join(folder, 'modules')
-gcc_srcdir = os.path.join(folder, '..', 'gcc')
+# -- Project information -----------------------------------------------------
 
-sys.path.insert(0, doc_modules)
 
 def read_file(name):
-    path = os.path.join(gcc_srcdir, name)
-    if os.path.exists(path):
+    path = gcc_srcdir / name
+    if path.exists():
         return open(path).read().strip()
     else:
         return ''
 
+
 def __get_builder_name():
     if '-b' in sys.argv:
         return sys.argv[sys.argv.index('-b') + 1]
@@ -124,14 +126,14 @@ html_theme_options = {
     'navigation_with_keys': True,
 }
 
-html_logo = os.path.join(folder, 'logo.svg')
+html_logo = str(folder / 'logo.svg')
 
-html_favicon = os.path.join(folder, 'favicon.ico')
+html_favicon = str(folder / 'favicon.ico')
 
 html_last_updated_fmt = ''
 
 html_static_path = [
-    os.path.join(folder, '_static')
+    str(folder / '_static')
 ]
 
 html_css_files = [
@@ -149,7 +151,7 @@ suppress_warnings = [
 # Use xelatex by default
 latex_engine = 'xelatex'
 
-latex_logo = os.path.join(folder, 'logo.pdf')
+latex_logo = str(folder / 'logo.pdf')
 
 latex_elements = {
     'pointsize': '11pt',
@@ -215,4 +217,4 @@ def set_common(name, module):
         module['tags'].add('development')
 
     html_theme_options['source_edit_link'] = f'https://gcc.gnu.org/onlinedocs/{name}' \
-                                               '/_sources/{filename}.txt'
+                                             '/_sources/{filename}.txt'
-- 
2.38.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-10  5:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10  5:33 [PATCH (pushed)] doc: Modernize baseconf.py Martin Liška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).