source: MML/trunk/machine/SOLEIL/common/toolbox/GUILayout/layoutHelp/doc.m

Last change on this file was 17, checked in by zhangj, 10 years ago

To have a stable version on the server.

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1function doc( funcname )
2%DOC  a wrapper for the built-in "doc" that also finds user documentation
3%
4%   DOC(FUNCNAME) tries to find HTML help for the function, class or
5%   method FUNCNAME. It first searches the MATLAB path for FUNCNAME.html,
6%   and if this is not found calls the built-in "doc" function to scan the
7%   built-in help files. This is needed because the "doc" command in R2007a
8%   and above no longer searches the MATLAB path for help files (it did for
9%   R14 up to R2006b). Once this is fixed this hack should be removed.
10
11%   Copyright 2007 The MathWorks Ltd.
12%   1.1   
13%   2012/05/08 08:02:53
14
15if nargin
16    if ischar( funcname )
17        w = which( [funcname,'.html'] );
18    elseif ishandle( funcname )
19        switch upper( get( funcname, 'type' ) )
20            case 'BLOCK'
21                funcname = iResolveSimulinkBlockType( funcname );
22            otherwise
23                error( 'doc:BadArg', 'Cannot find documentation for object of type ''%s''', get( funcname, 'type' ) );
24        end
25        if isempty(funcname)
26            error( 'doc:BadArg', 'Object returned empty type description' );
27        else
28            w = which( [funcname,'.html'] );
29        end
30    end
31else
32    w = [];
33end
34if isempty(w)
35    % To get a function handle to the original function we first have to CD
36    % to its directory, then get a handle, then return to where we were.
37    % Urgh! Just horrible.
38    olddir = pwd();
39    origpath = fullfile( matlabroot(), 'toolbox', 'matlab', 'helptools' );
40    cd(origpath);
41    orig_doc = str2func( 'doc' );
42    cd(olddir);
43   
44    % OK, we have the handle, so call it
45    if nargin
46        feval( orig_doc, funcname );
47    else
48        feval( orig_doc );
49    end
50else
51    web(w, '-helpbrowser'); % was helpview(w) but gave Java issues - DJA
52end
53
54function type = iResolveSimulinkBlockType( block )
55% Simulink block. The block type can be in many places
56% according to how the block was constructed so we need to
57% check the type
58block_type = get( block, 'BlockType' );
59switch upper( block_type )
60    case 'SUBSYSTEM'
61        type = get( block, 'MaskType' );
62    otherwise
63        error( 'doc:BadArg', 'Simulink block type ''%s'' is not yet supported', block_type );
64end
65
Note: See TracBrowser for help on using the repository browser.