Skip to content

Commit 0aec693

Browse files
authored
Merge pull request #212 from AdvancedPhotonSource/newhelp
Implement MarkDown-generated Help
2 parents 5c084c5 + 6beb549 commit 0aec693

File tree

329 files changed

+71419
-187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+71419
-187
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: xfer help info from GSAS-II docs repo
2+
3+
on:
4+
workflow_dispatch:
5+
6+
push:
7+
branches:
8+
- newhelp
9+
10+
permissions:
11+
contents: write
12+
id-token: write
13+
pages: write
14+
15+
jobs:
16+
build: # Build web pages
17+
runs-on: ubuntu-latest
18+
steps:
19+
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Python setup
24+
uses: actions/setup-python@v3
25+
26+
- name: mkdocs setup
27+
run: |
28+
pip install mkdocs mkdocs-material python-markdown-math mkdocs-static-i18n
29+
pip install mkdocs-to-pdf pymdown-extensions
30+
31+
# get the new help pages from GSAS-II docs
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
35+
repository: AdvancedPhotonSource/GSAS-II-tutorials.git
36+
path: _docs
37+
ref: newhelp
38+
# token: ''
39+
40+
# MD help conversion
41+
- name: convert MDhelp
42+
run: |
43+
pwd
44+
cd _docs/MDhelp
45+
mkdocs build
46+
python findMDanchors.py # create an anchor index
47+
rm -rf ../../GSASII/help/assets/javascripts/
48+
rm -rf ../../GSASII/help/assets/stylesheets/
49+
cp -vr site/* ../../GSASII/help
50+
51+
- name: git diagnostics
52+
run: |
53+
pwd
54+
git status
55+
git diff
56+
git add GSASII/help
57+
echo "After add"
58+
git status
59+
60+
- name: commit changes
61+
run: |
62+
pwd
63+
git add GSASII/help
64+
git config user.name "github-actions[bot]"
65+
git config user.email "github-actions[bot]@users.noreply.github.com"
66+
git commit -m"update help files"
67+
68+
- name: push help into repo
69+
run: |
70+
git push

GSASII/GSASIIctrlGUI.py

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5900,13 +5900,13 @@ def __init__(self,frame,includeTree=False,morehelpitems=[]):
59005900
helpobj = self.Append(wx.ID_ANY,lbl,'')
59015901
frame.Bind(wx.EVT_MENU, self.OnHelpById, helpobj)
59025902
self.HelpById[helpobj.GetId()] = indx
5903-
# add help lookup(s) in gsasii.html
5903+
# add help lookup(s) in GSAS-II Help
59045904
self.AppendSeparator()
59055905
if includeTree:
59065906
helpobj = self.Append(wx.ID_ANY,'Help on GSAS-II',
5907-
'Access web page with information on GSAS-II')
5907+
'Access web pages with information on GSAS-II')
59085908
frame.Bind(wx.EVT_MENU, self.OnHelpById, id=helpobj.GetId())
5909-
self.HelpById[helpobj.GetId()] = 'Data tree'
5909+
self.HelpById[helpobj.GetId()] = 'HelpIntro'
59105910
helpobj = self.Append(wx.ID_ANY,'Help on current data tree item\tF1',
59115911
'Access web page on selected item in tree')
59125912
frame.Bind(wx.EVT_MENU, self.OnHelpById, id=helpobj.GetId())
@@ -5916,21 +5916,18 @@ def __init__(self,frame,includeTree=False,morehelpitems=[]):
59165916

59175917
def OnHelpById(self,event):
59185918
'''Called when Help on... is pressed in a menu. Brings up a web page
5919-
for documentation. Uses the helpKey value from the dataWindow window
5920-
unless a special help key value has been defined for this menu id in
5921-
self.HelpById
5922-
5923-
Note that self should now (2frame) be child of the main window (G2frame)
5919+
for documentation. Uses the G2frame.dataWindow.helpKey value to select
5920+
what help is shown, unless a special help key value has been defined
5921+
for the calling menu id (via a lookup in self.HelpById[], which is used
5922+
for Tutorials & Overall help).
5923+
Note that G2frame.dataWindow.helpKey SelectDataTreeItem and reflects
5924+
the data tree item that has been selected.
5925+
5926+
Note that self here should be a child of the main window (G2frame)
5927+
where self.frame is G2frame
59245928
'''
5925-
if hasattr(self.frame,'dataWindow'): # Debug code: check this is called from menu in G2frame
5926-
# should always be true in 2 Frame version
5927-
dW = self.frame.dataWindow
5928-
else:
5929-
print('help error: not called from standard menu?')
5930-
print (self)
5931-
return
59325929
try:
5933-
helpKey = dW.helpKey # look up help from helpKey in data window
5930+
helpKey = self.frame.dataWindow.helpKey # look up help from helpKey in data window
59345931
#if GSASIIpath.GetConfigValue('debug'): print 'DBG_dataWindow help: key=',helpKey
59355932
except AttributeError:
59365933
helpKey = ''
@@ -6035,7 +6032,7 @@ def copy2clip(event):
60356032
class HelpButton(wx.Button):
60366033
'''Create a help button that displays help information.
60376034
The text can be displayed in a modal message window or it can be
6038-
a reference to a location in the gsasII.html (etc.) help web page, in which
6035+
a reference to a location in the gsasII help web pages, in which
60396036
case that page is opened in a web browser.
60406037
60416038
TODO: it might be nice if it were non-modal: e.g. it stays around until
@@ -6046,9 +6043,12 @@ class HelpButton(wx.Button):
60466043
:param str msg: the help text to be displayed. Indentation on
60476044
multiline help text is stripped (see :func:`StripIndents`). If wrap
60486045
is set as non-zero, all new lines are
6049-
:param str helpIndex: location of the help information in the gsasII.html
6050-
help file in the form of an anchor string. The URL will be
6051-
constructed from: location + gsasII.html + "#" + helpIndex
6046+
:param str helpIndex: selection for the help information in the GSAS-II
6047+
help files, in the form of an anchor string. That anchor is looked
6048+
up to find the file name and the URL is constructed from:
6049+
6050+
<location> + <filename> + "#" + helpIndex
6051+
60526052
:param int wrap: if specified, the text displayed is reformatted by
60536053
wrapping it to fit in wrap pixels. Default is None which prevents
60546054
wrapping.
@@ -7626,22 +7626,31 @@ class G2LstCtrl(wx.ListCtrl):
76267626
htmlPanel = None
76277627
htmlFrame = None
76287628
htmlFirstUse = True
7629-
#helpLocDict = {} # to be implemented if we ever split gsasii.html over multiple files
7629+
helpLocDict = {}
7630+
'This is an index to the HTML anchors defined in the GSAS-II help files'
76307631
path2GSAS2 = os.path.dirname(os.path.realpath(__file__)) # save location of this file
76317632
def ShowHelp(helpType,frame,helpMode=None):
76327633
'''Called to bring up a web page for documentation.'''
76337634
global htmlFirstUse,htmlPanel,htmlFrame
7635+
if not helpLocDict: # load the anchor index
7636+
indx = os.path.abspath(os.path.join(path2GSAS2,'help','anchorIndex.txt'))
7637+
print('reading file',indx)
7638+
with open(indx,'r') as indexfile:
7639+
for line in indexfile.readlines():
7640+
fil,anchors = line.split(':')
7641+
for a in anchors.split(','):
7642+
#if a in helpLocDict: print(a,'repeated!')
7643+
helpLocDict[a.strip()] = fil
76347644
# no defined link to use, create a default based on key
7635-
if helpType.lower().startswith('pwdr'):
7636-
helplink = 'gsasII-pwdr.html#'+helpType.replace(')','').replace('(','_').replace(' ','_')
7637-
elif helpType.lower().startswith('phase'):
7638-
helplink = 'gsasII-phase.html#'+helpType.replace(')','').replace('(','_').replace(' ','_')
7639-
elif helpType.lower().startswith('hist/phase'):
7640-
helplink = 'gsasII-phase.html#Phase-Data'
7641-
elif helpType:
7642-
helplink = 'gsasII.html#'+helpType.replace(')','').replace('(','_').replace(' ','_')
7643-
else:
7644-
helplink = 'gsasII.html'
7645+
helplink = 'index.html'
7646+
if helpType:
7647+
anchor = helpType.replace(')','').replace('(','_').replace(' ','_')
7648+
if anchor not in helpLocDict:
7649+
print(f'Help lookup problem, anchor {anchor} not found'
7650+
'\nPlease report this to [email protected] along with a'
7651+
'\nscreen image showing where you tried to get help')
7652+
else:
7653+
helplink = f'{helpLocDict[anchor]}#{anchor}'
76457654
# determine if a web browser or the internal viewer should be used for help info
76467655
if helpMode:
76477656
pass

GSASII/GSASIIdataGUI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8564,7 +8564,7 @@ def OnShowShift(event):
85648564
parentID = G2frame.root
85658565
if item == G2frame.root:
85668566
G2frame.dataWindow.ClearData()
8567-
G2frame.helpKey = "Data tree"
8567+
G2frame.dataWindow.helpKey = "Data tree"
85688568
mainSizer = wx.BoxSizer(wx.VERTICAL)
85698569
G2frame.dataWindow.SetSizer(mainSizer)
85708570
mainSizer.Add(wx.StaticText(G2frame.dataWindow, wx.ID_ANY,

GSASII/GSASIIplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def FindPlotTab(self,label,Type,newImage=True,publish=None):
463463
try:
464464
Page.helpKey = self.G2frame.dataWindow.helpKey
465465
except AttributeError:
466-
Page.helpKey = 'Data tree'
466+
Page.helpKey = 'HelpIntro'
467467
return new,plotNum,Page,Plot,limits
468468

469469
def _addPage(self,name,page):

0 commit comments

Comments
 (0)