Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08801db

Browse files
committed
The MacPython introductory help is now called MacPython Help, and the
optional full documentation Python Documentation.
1 parent f3ef038 commit 08801db

4 files changed

Lines changed: 41 additions & 25 deletions

File tree

Mac/OSX/Doc/setup.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def initialize_options(self):
3232
self.build_html = None
3333
self.build_dest = None
3434
self.download = 1
35-
self.doc_version = '2.2.1'
35+
self.doc_version = '2.2.2'
3636

3737
def finalize_options(self):
3838
build.finalize_options(self)
@@ -46,13 +46,20 @@ def spawn(self, *args):
4646

4747
def downloadDocs(self):
4848
workdir = os.getcwd()
49-
self.mkpath(self.build_html)
49+
url = 'http://www.python.org/ftp/python/doc/%s/html-%s.tgz' % \
50+
(self.doc_version,self.doc_version)
5051
os.chdir(self.build_base)
51-
self.spawn('curl','-O', 'http://www.python.org/ftp/python/doc/%s/html-%s.tgz' % (self.doc_version,self.doc_version))
52-
os.chdir(workdir)
53-
os.chdir(self.build_html)
54-
self.spawn('tar', '-xzf', '../html-%s.tgz' % self.doc_version)
52+
self.spawn('curl','-O', url)
5553
os.chdir(workdir)
54+
tarfile = 'html-%s.tgz' % self.doc_version
55+
## This no longer works due to name changes
56+
## self.mkpath(self.build_html)
57+
## os.chdir(self.build_html)
58+
## self.spawn('tar', '-xzf', '../' + tarfile)
59+
## os.chdir(workdir)
60+
print "** Please unpack %s" % os.path.join(self.build_base, tarfile)
61+
print "** Unpack the files into %s" % self.build_html
62+
raise RuntimeError, "You need to unpack the docs manually"
5663

5764
def buildDocsFromSource(self):
5865
srcdir = '../../..'
@@ -75,7 +82,7 @@ def hackIndex(self):
7582
hackedIndex = file(os.path.join(self.build_dest, ind_html),'w')
7683
origIndex = file(os.path.join(self.build_html,ind_html))
7784
r = re.compile('<style type="text/css">.*</style>', re.DOTALL)
78-
hackedIndex.write(r.sub('<META NAME="AppleTitle" CONTENT="Python Help">',origIndex.read()))
85+
hackedIndex.write(r.sub('<META NAME="AppleTitle" CONTENT="Python Documentation">',origIndex.read()))
7986

8087
def hackFile(self,d,f):
8188
origPath = os.path.join(d,f)
@@ -107,6 +114,7 @@ def makeHelpIndex(self):
107114

108115
def run(self):
109116
self.ensure_finalized()
117+
self.mkpath(self.build_base)
110118
self.ensureHtml()
111119
if not os.path.isdir(self.build_html):
112120
raise RuntimeError, \
@@ -142,7 +150,7 @@ def finalize_options(self):
142150
build_cmd = self.get_finalized_command('build')
143151
self.build_dest = build_cmd.build_dest
144152
if self.install_doc == None:
145-
self.install_doc = os.path.join(self.prefix, 'Resources/English.lproj/Documentation')
153+
self.install_doc = os.path.join(self.prefix, 'Resources/Python.app/Contents/Resources/English.lproj/PythonDocumentation')
146154
print 'INSTALL', self.build_dest, '->', self.install_doc
147155

148156
def run(self):

Mac/OSXResources/app/Info.plist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
<key>CFBundleHelpBookFolder</key>
3333
<array>
3434
<string>Documentation</string>
35+
<string>PythonDocumentation</string>
3536
</array>
3637
<key>CFBundleHelpBookName</key>
37-
<string>Python Help</string>
38+
<string>MacPython Help</string>
3839
<key>CFBundleHelpTOCFile</key>
3940
<string>index.html</string>
4041

Mac/OSXResources/app/Resources/English.lproj/Documentation/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="generator" content="BBEdit 6.5.3">
88
<link rel="SHORTCUT ICON" href="pythonsmall.gif">
99
<META NAME="AppleIcon" CONTENT="pythonsmall.gif">
10-
<META NAME="AppleTitle" CONTENT="Python Help">
10+
<META NAME="AppleTitle" CONTENT="MacPython Help">
1111
</head>
1212
<body>
1313

Mac/Tools/IDE/PythonIDEMain.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,14 @@ def domenu_openpackagemanager(self):
353353
PackageManager.PackageBrowser()
354354

355355
def makehelpmenu(self):
356-
docs = self.installdocumentation()
356+
hashelp, hasdocs = self.installdocumentation()
357357
self.helpmenu = m = self.gethelpmenu()
358+
helpitem = FrameWork.MenuItem(m, "MacPython Help", None, self.domenu_localhelp)
359+
helpitem.enable(hashelp)
358360
docitem = FrameWork.MenuItem(m, "Python Documentation", None, self.domenu_localdocs)
359-
docitem.enable(docs)
361+
docitem.enable(hasdocs)
360362
finditem = FrameWork.MenuItem(m, "Lookup in Python Documentation", None, 'lookuppython')
361-
finditem.enable(docs)
363+
finditem.enable(hasdocs)
362364
if runningOnOSX():
363365
FrameWork.Separator(m)
364366
doc2item = FrameWork.MenuItem(m, "Apple Developer Documentation", None, self.domenu_appledocs)
@@ -370,7 +372,11 @@ def makehelpmenu(self):
370372

371373
def domenu_localdocs(self, *args):
372374
from Carbon import AH
373-
AH.AHGotoPage("Python Help", None, None)
375+
AH.AHGotoPage("Python Documentation", None, None)
376+
377+
def domenu_localhelp(self, *args):
378+
from Carbon import AH
379+
AH.AHGotoPage("MacPython Help", None, None)
374380

375381
def domenu_appledocs(self, *args):
376382
from Carbon import AH, AppleHelp
@@ -388,7 +394,7 @@ def domenu_lookuppython(self, *args):
388394
if not searchstring:
389395
return
390396
try:
391-
AH.AHSearch("Python Help", searchstring)
397+
AH.AHSearch("Python Documentation", searchstring)
392398
except AH.Error, arg:
393399
W.Message("AppleHelp Error: %s" % `arg`)
394400

@@ -441,16 +447,17 @@ def installdocumentation(self):
441447
# And as AHRegisterHelpBook wants a bundle (with the right bits in
442448
# the plist file) we refer it to Python.app
443449
python_app = os.path.join(sys.prefix, 'Resources/Python.app')
444-
doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation')
445-
if not os.path.isdir(doc_source):
446-
return 0
447-
try:
448-
from Carbon import AH
449-
AH.AHRegisterHelpBook(python_app)
450-
except (ImportError, MacOS.Error), arg:
451-
W.Message("Cannot register Python documentation: %s" % `arg`)
452-
return 0
453-
return 1
450+
help_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation')
451+
doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/PythonDocumentation')
452+
has_help = os.path.isdir(help_source)
453+
has_doc = os.path.isdir(doc_source)
454+
if has_help or has_doc:
455+
try:
456+
from Carbon import AH
457+
AH.AHRegisterHelpBook(python_app)
458+
except (ImportError, MacOS.Error), arg:
459+
pass # W.Message("Cannot register Python Documentation: %s" % str(arg))
460+
return has_help, has_doc
454461

455462

456463
PythonIDE()

0 commit comments

Comments
 (0)