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
|
Description: 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.
From: Neil Williams <codehelp@debian.org>
Date: Fri 1 Apr 11:19:54 BST 2022
---
--- a/setup.py
+++ b/setup.py
@@ -210,6 +210,7 @@
#'sphinx>=1.6.2',
# 'openpyxl', 'distro'
'pandas', 'OpenGL', 'spyder',
+ 'sphinx', 'xdg',
],
classifiers=['Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
--- a/xrt/gui/commons/ext.py
+++ b/xrt/gui/commons/ext.py
@@ -6,6 +6,7 @@
import sys
import os
import os.path as osp
+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,11 +32,13 @@
isSpyderConsole = False
isSphinx = True
-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"]
CSS_PATH = osp.join(CONFDIR, '_static')
CSS_PATH = re.sub('\\\\', '/', CSS_PATH)
JS_PATH = CSS_PATH
-xrtQookPageName = 'xrtQookPage'
xrtQookPage = 'file:///' + osp.join(CONFDIR, xrtQookPageName+'.html')
xrtQookPage = re.sub('\\\\', '/', xrtQookPage)
@@ -77,6 +80,9 @@
if not os.path.exists(srcdir):
os.makedirs(srcdir)
# srcdir = encoding.to_unicode_from_fs(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'
|