Discussion:
[BitPim-devel] Apple help
Roger Binns
2005-01-28 18:11:08 UTC
Permalink
Enough of my time has been wasted by this. I have been trying to get
BitPim to use the native help system on Mac. In the end I failed due
to gaping holes in Apple's documentation. If someone else can figure
out the answers to these questions I'll go ahead and change things,
otherwise you'll just have to stick with wxWidgets help system.

The documentation is at
http://developer.apple.com/documentation/Carbon/Conceptual/
ProvidingUserAssitAppleHelp/index.html

You can turn the BitPim help into help that conforms with the above by
doing the following:

- Make a directory somewhere
- Extract resources/bitpim.htb using unzip into that directory
- Edit welcome.htm to add a tag in the head section: <META
="AppleTitle" CONTENT="BitPim help">
- Drag and drop the folder onto the help indexing tool (It is in
/Developer/Applications/Utilities). (For some reason Apple go out of
their way to ensure you can't run this tool from the command line).

According to the doc that is all that is necessary to make a
non-localized help book. To use it you can do the following:

import Carbon.AH
Carbon.AH.AHGotoPage(None, "file:///path/to/welcome.htm", None)

That will correctly bring up the help. However the search function
won't work, and it thinks the book title is (null). (So what exactly
was the point of the meta tag above then? Why does it ignore the index
it created?)

Presumably some pieces are missing. Maybe you have to use the
Carbon.AH.AHRegisterHelpBook function (I couldn't find any parameter
that would not give an error). There is probably a property list file
that should be somewhere although the online documentation doesn't say
where (in that directory, in a parent directory, somewhere else?). It
also doesn't say how to create a property list from the command line
even if I knew where to put it, nor what it actually needs to contain.

Note that I am trying to create a standalone non-localized help book
that is not part of any other bundle or even of BitPim, and do so
entirely from the command line.

And I have to admit that the more I use MacOS, the less and less
impressed I am. It feels very comparable to Linux GUI environments
with applications randomly incomplete, appalling documentation, lots of
unpolished corners and some sort of promise that you should excuse all
this because of how much better it will be in the future.

Roger
Adit Panchal
2005-01-29 10:38:56 UTC
Permalink
Post by Roger Binns
According to the doc that is all that is necessary to make a
import Carbon.AH
Carbon.AH.AHGotoPage(None, "file:///path/to/welcome.htm", None)
That will correctly bring up the help. However the search function
won't work, and it thinks the book title is (null). (So what exactly
was the point of the meta tag above then? Why does it ignore the
index it created?)
I got this working as well. I was able to put in keywords and a
description and recreated the index file. The indexing tool detected
the keywords and description fine, but when I searched the help, it
still did nothing. I believe this means that the help HAS to be
registered for the search to work properly - it's probably also the
reason that null is showing up, since it doesn't know what book to
search (kind of dumb if you ask me - the idx file is right there).
Post by Roger Binns
Presumably some pieces are missing. Maybe you have to use the
Carbon.AH.AHRegisterHelpBook function (I couldn't find any parameter
that would not give an error). There is probably a property list file
that should be somewhere although the online documentation doesn't say
where (in that directory, in a parent directory, somewhere else?). It
also doesn't say how to create a property list from the command line
even if I knew where to put it, nor what it actually needs to contain.
The property list they speak of is set within the Info.plist that comes
with bundled applications. If I am not mistaken, this needs to be set
in the build script. I put this in but as you will read below, I never
got a chance to test it. So it seems that unfortunately, to tie in
standalone help without a bundle doesn't seem like a possibility.
Post by Roger Binns
Note that I am trying to create a standalone non-localized help book
that is not part of any other bundle or even of BitPim, and do so
entirely from the command line.
Anyways, on trying to get this to work, I wanted to perform a build and
put the help inside. Unfortunately, I couldn't get the build script
working, even before playing around with the help. I have all of the
necessary libraries and running bp.py works without a hitch. Whenever I
use makedist.py or write my own setup script with py2app, I get the
following error. I tried to look online to see what it could be, but
after searching various malling-lists, there was only one case similar
to my error. The individual had mentioned that he had an image file in
his source directory that was causing problems. I could did build
superdoodle.py which comes with py2app, and that builds just perfectly.
Any clues? Maybe it is just my system.

Traceback (most recent call last):
File "makedist.py", line 430, in ?
macbuild()
File "makedist.py", line 409, in macbuild
setup( data_files = resources(), options = opts, app = app,
script_args = ("py2app",) )
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/distutils/core.py", line 149, in setup
dist.run_commands()
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/distutils/dist.py", line 907, in run_commands
self.run_command(cmd)
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/distutils/dist.py", line 927, in run_command
cmd_obj.run()
File "/purelib/py2app/py2app/build_app.py", line 281, in run
File "/purelib/py2app/py2app/build_app.py", line 366, in _run
File "/purelib/py2app/py2app/build_app.py", line 414, in run_normal
File "/purelib/py2app/py2app/build_app.py", line 329, in
get_modulefinder
File "/purelib/py2app/modulegraph/find_modules.py", line 241, in
find_modules
File "/purelib/py2app/modulegraph/find_modules.py", line 163, in
find_needed_modules
File "/purelib/py2app/modulegraph/modulegraph.py", line 236, in
run_script
File "/purelib/py2app/modulegraph/modulegraph.py", line 456, in
scan_code
File "/purelib/py2app/modulegraph/modulegraph.py", line 404, in
_safe_import_hook
File "/purelib/py2app/modulegraph/modulegraph.py", line 246, in
import_hook
File "/purelib/py2app/modulegraph/modulegraph.py", line 306, in
load_tail
File "/purelib/py2app/modulegraph/modulegraph.py", line 362, in
import_module
File "/purelib/py2app/modulegraph/modulegraph.py", line 397, in
load_module
File "/purelib/py2app/modulegraph/modulegraph.py", line 456, in
scan_code
File "/purelib/py2app/modulegraph/modulegraph.py", line 404, in
_safe_import_hook
File "/purelib/py2app/modulegraph/modulegraph.py", line 245, in
import_hook
File "/purelib/py2app/modulegraph/modulegraph.py", line 291, in
find_head_package
File "/purelib/py2app/modulegraph/modulegraph.py", line 362, in
import_module
File "/purelib/py2app/modulegraph/modulegraph.py", line 397, in
load_module
File "/purelib/py2app/modulegraph/modulegraph.py", line 456, in
scan_code
File "/purelib/py2app/modulegraph/modulegraph.py", line 404, in
_safe_import_hook
File "/purelib/py2app/modulegraph/modulegraph.py", line 245, in
import_hook
File "/purelib/py2app/modulegraph/modulegraph.py", line 284, in
find_head_package
File "/purelib/py2app/modulegraph/modulegraph.py", line 362, in
import_module
File "/purelib/py2app/modulegraph/modulegraph.py", line 376, in
load_module
TypeError: compile() expected string without null bytes

Thanks,

Adit
Roger Binns
2005-01-30 04:53:03 UTC
Permalink
it's probably also the reason that null is showing up, since it
doesn't know what book to search (kind of dumb if you ask me - the idx
file is right there).
And the AppleTitle meta tag is present. Why put that in if it has no
effect?
So it seems that unfortunately, to tie in standalone help without a
bundle doesn't seem like a possibility.
I believe that the help can be done as a standalone bundle that you can
register with AHRegisterHelpBook. The problem is that the
documentation doesn't say exactly how it should be laid out. (Or more
accurately it says do A, then B, then C and everything should be fine
as you do G and H. The crucial pieces of information are in the
middle.)

My meta-goal in this is to be able to have a script that can turn any
wxWidgets format help into Apple conformant help, rather than some ugly
hack that temporarily solves it only for BitPim.
Whenever I use makedist.py or write my own setup script with py2app, I
get the following error.
It definitely works (I just tried again). You will get an error
somewhere due to py2app not working correctly with optimize=2 in the
options (it fails to find 3 files). I have a hack which I had thought
I posted but can't find, so here it is again.

Edit /Library/Python/2.3/py2app/py2app/util.py around line 205 and add
the bits between the hash signs. I kept some context on either side:

if target_dir:
cfile = os.path.join(target_dir, dfile)

###
### Hack to work around bug in py2app with optimize
###
if not os.path.exists(mod.filename):
import py2app

bootstrapname=os.path.join(os.path.dirname(py2app.__file__),
"bootstrap", mod.filename)
if os.path.exists(bootstrapname):
mod.filename=bootstrapname
###
### End hack
###
TypeError: compile() expected string without null bytes
You may need to use ktrace or python -v to figure out where that is
happening. In my experience you can end up with nulls in a file if
there have been disk issues or a screwup with CVS. Try on a clean
checkout.

Roger

Loading...