1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
From: Neil Williams <codehelp@debian.org>
Date: Fri, 1 Apr 2022 11:19:54 +0100
Subject: Allow sphinx generation in XDG cache directory
The in-gui help pages are generated at runtime using
python3-sphinx as a single rewritten HTML page. Locate
that page in a user-writeable cache and symlink the
necessary support files.
---
setup.py | 2 +-
xrt/gui/commons/ext.py | 12 ++++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/setup.py b/setup.py
index 061a718..5dacdfd 100644
--- a/setup.py
+++ b/setup.py
@@ -202,7 +202,7 @@ setup(
scripts=['xrt/gui/xrtQookStart'],
install_requires=['numpy>=1.8.0', 'scipy>=0.17.0', 'matplotlib>=2.0.0',
'sphinx>=1.6.2', 'sphinxcontrib-jquery', 'distro',
- 'colorama', 'pandas', 'OpenGL', 'spyder'
+ 'colorama', 'pandas', 'OpenGL', 'spyder', 'xdg'
# 'openpyxl',
],
classifiers=['Development Status :: 5 - Production/Stable',
diff --git a/xrt/gui/commons/ext.py b/xrt/gui/commons/ext.py
index 08c496a..a328219 100644
--- a/xrt/gui/commons/ext.py
+++ b/xrt/gui/commons/ext.py
@@ -7,6 +7,7 @@ import sys
import os
import os.path as osp
import shutil
+import xdg
# Spyderlib modules can reside in either Spyder or Spyderlib, so we check both
# It's definitely not the optimal solution, but it works.
@@ -31,7 +32,11 @@ except (ImportError, KeyError):
except (ImportError, KeyError):
isSpyderConsole = False
-CONFDIR = osp.dirname(osp.abspath(__file__))
+xrtQookPageName = 'xrtQookPage'
+CONFDIR = osp.join(xdg.xdg_cache_home(), xrtQookPageName)
+SYS_COMMONS_DIR = osp.dirname(osp.abspath(__file__))
+SPHINX_LINKS = ["conf.py", "_images", "_themes"]
+
DOCDIR = osp.expanduser(osp.join('~', '.xrt', 'doc'))
try:
shutil.rmtree(DOCDIR)
@@ -45,10 +50,10 @@ CSS_PATH = osp.join(DOCDIR, '_static')
CSS_PATH = re.sub('\\\\', '/', CSS_PATH)
JS_PATH = CSS_PATH
-xrtQookPageName = 'xrtQookPage'
xrtQookPage = 'file:///' + osp.join(DOCDIR, xrtQookPageName+'.html')
xrtQookPage = re.sub('\\\\', '/', xrtQookPage)
+
from . import qt
shouldScaleMath = qt.QtName == "PyQt4" and sys.platform == 'win32'
@@ -86,6 +91,9 @@ def sphinxify(docstring, context, buildername='html', img_path=''):
srcdir = osp.join(DOCDIR, '_sources')
if not osp.exists(srcdir):
os.makedirs(srcdir)
+ for link in SPHINX_LINKS:
+ if not osp.exists(osp.join(CONFDIR, link)):
+ os.symlink(osp.join(SYS_COMMONS_DIR, link), osp.join(CONFDIR, link))
base_name = osp.join(srcdir, xrtQookPageName)
rst_name = base_name + '.rst'
|