Need help regarding publish problem....
1 view (last 30 days)
Show older comments
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164652/image.jpeg)
Why it is showing code which i have written in help. It should show output jut like it should in help window as following.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164653/image.jpeg)
So how i can overcome this problem??
1 Comment
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.
Accepted Answer
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.
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
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.
More Answers (0)
See Also
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!