Need help regarding publish problem....

14 views (last 30 days)
I have attached a file named test2.m when i publish it using simple publish button. and then search its help in command window using help test2.m its output is following
Why it is showing code which i have written in help. It should show output jut like it should in help window as following.
So how i can overcome this problem??
  1 Comment
Chad Greene
Chad Greene on 22 Jun 2014
Mujhaid, For this question and any question you ask on this forum, please choose "accept answer" if someone provides an answer that solves your problem. This helps readers with similar problems identify the best solution. It's also a nice way to let folks know when their efforts have helped you.

Sign in to comment.

Accepted Answer

Geoff Hayes
Geoff Hayes on 22 Jun 2014
Mujhaid - using publish to publish some code in a script or m-file and running help or doc on a function are two different options (see http://www.mathworks.com/help/matlab/matlab_prog/summary-of-options-for-presenting-your-code-to-others.html) and it can't be assumed that the way one works should work identically for the other.
Each has its own syntax or rules in setting up the help specific to the option. Using help or doc seems to look for a comment block that is above or below the function signature. It uses that in its help documentation this is presented to the user. That is why you are seeing all the publish markup code in the Command Window. Having the html folder of the published functions (or scripts) in the same directory as the function (or script) that you are requesting help on seems to add the
Published output in the Help browser
showdemo test2
comments and link whenever you evaluate help test2.
I suppose that one way to satisfy the help and doc commands against your function and to publish the data is as follows: write the help friendly comments above the function signature, and write the publish friendly comments below the function signature
% TEST2 Does some stuff
% C = test2(A) does something with A
% C = test2(A,B) does something with A and B
%
% See also AXIS, GRID.
function [C] = test2(A,B)
code for the publish function.
help for the axis function.
Now for help grid function.
Now when you go to publish this file, export the html file to some directory other than html in the directory of the (in this case) test2.m file. Or not, and just accept the fact that when you type help test2 you will see the following
test2 Does some stuff
C = test2(A) does something with A
C = test2(A,B) does something with A and B
See also axis, grid.
Published output in the Help browser
showdemo test2
with the additional Published output in the Help browser….
There is some duplication in the comments (and the one above the function signature will appear in the published file) but it does satisfy the help and publish options.
Try the above and see what happens!
  2 Comments
Mujhaid
Mujhaid on 24 Jun 2014
Thanks a lot for your help Geoff Hayes i have tried your suggestion and it is working quite well. but why it don,t publish following lines of code.
%%
% <matlab:edit(fullfile(matlabroot,'toolbox','matlab','codetools','publish.m')) code>
% for the publish function.
%
% help for the <matlab:doc('axis') axis> function.
%
% Now for help <matlab:doc('grid') grid> function.
As i am interested in created internal linking. internal linking means when i click some function it should go to help page of that function. just take example of
help figure
it opes help page of figure following is snap shoot of that help page
So arrows point to functions these are internal links.
so i can create these internal links in making help page of any function?
Geoff Hayes
Geoff Hayes on 24 Jun 2014
Mujhaid - you would have to provide an example of what you want to do that is not working as publishing the test2.m with the code from above does work.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!