Code covered by the BSD License  

Highlights from
Publish dependent and called functions

4.6

4.6 | 5 ratings Rate this file 126 Downloads (last 30 days) File Size: 4.55 KB File ID: #33476

Publish dependent and called functions

by

 

26 Oct 2011 (Updated )

Publish explicitly called functions not found in the MATLAB root. See mfile for limitations.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

  publishdepfun creates a single published html file with called
  functions attached to the end of the root mfile. Hyperlinks will be
  within a "Called Functions" in the Table of Contents area of the
  published document that link to the called function. Functions that are
  called that are under MATLABROOT are not included in the published
  output.
 
  publishdepfun only goes one level deep....
  
  Example: If fun1 calls fun2, fun2 will be published. If fun2 calls fun3,
           fun3 will not be published.
 
  Calling: new_doc = publishdepfun(func,opts)
  
  Inputs:
 
  * func => character string of root function or script ('Function1').
            The ".m" is not needed.
  * opts => is the list of options for the publishing. See publish.m help
            for more information.
 * add_fun => is a cell array of additional functions to be published.
 * rm_fun => is a cell array of functions to remove from publish list.
 
  Outputs:
 
  * new_doc => the final html document with attached subfunctions.
                    Name is the root file name with "_withfuncs" appended.

Acknowledgements

This file inspired Publish The Main And The Subfunctions Together.

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
17 Sep 2014 Valeria

Hi, is there a way to avoid multiple publishing of subfunctions that are called multiple times? Let's say for instance that I have created an auxiliary function that needs to be called twice with different argumetns. This way your tool will list it in the Called Functions twice and will attach it at the end of the document twice.
Thank you.

13 May 2014 Denis Anikiev  
30 May 2013 Nick Angelini

@jon there is not going to be a pdf version. This is simply spliced html code together. MATLAB uses a completely different method for creating pdfs. If you want pdfs look at the "Publish The Main And The Subfunctions Together". It creates a new mfile with all your functions then publishes it.

I don't know what you mean by doesn't publish first script alongside your functions.

The example makes two files. It creates a published file of all the files it thinks it needs and copies code from them into the "withfuncs" file.

If you think the code is not working properly either give me more info or send me the files so I can look at it.

24 May 2013 jon

Close but doesn't have pdf or publish my first script alongside my functions.

I have two separate files.. myfile & myfilewithfuncs. They are not a single file like the example makes.

I have two functions in separate scripts along with my main file. I also have one inline function.

05 Feb 2013 Nick Angelini

Updated to include ability to remove functions from publish list.

I can look into adding pdf output if I have time. It would take some effort considering I am splicing this together with html code and the default publish function does not create html code before making the pdf.

31 Jan 2013 Michael

This is great. I was wandering though if there is a way to suppress a particular function file? I am running a student version and I do not have the toolbox that includes the roundn function, so I am using one found here. I would rather this function not be published in order to keep my overall report looking better.

20 Nov 2012 SeungGyu cho

you're a jewel.

15 Oct 2012 Wang Jing

Great job! It will be perfect if the output can be pdf.

29 Sep 2012 Mohammad

Thanks for this code! It helped me to combine everything nicely for my programming class.

However, is there a way to combine everything into a .pdf? I'm currently copying everything published in HTML to Word and saving as a .pdf.

19 Mar 2012 Jiro Doke

@Nick,

Thanks for adding the web output in case of no output argument. "nargout" is the appropriate way to deal with that.

06 Mar 2012 Arvind

Thanks Nick... This is exactly what I needed

13 Feb 2012 Nick Angelini

Mikhail,

Thanks for finding that. I have added it to the file and have submitted the updated version.

07 Feb 2012 Mikhail

Thanks!

However, it also includes my called MEX functions into the generated report (which looks kinda weird in the report).

I added the following around line 95 to mitigate this particular behavior:

%% Remove hits that are probably MEX functions
idx=strfind(out,mexext);
for i=1:length(idx),
idxs(i) = ~isempty(idx{i});
end
out(idxs)=[];

23 Jan 2012 Nick Angelini

@Jiro

I have added some crude support for displaying the html document when no output argument is given. I just used nargout. Is there a more elegant solution?

19 Jan 2012 Jiro Doke

Very nice entry Nick!

This may be about preference, but it would be nice if I call the function without any output argument, then it would open the published HTML in the MATLAB browser. This is the same behavior as "publish".

Otherwise, I really like it. I plan on highlighting this entry for this week's Pick of the Week.

Thanks for the submission!

Updates
10 Jan 2012

Version 2
# added ability to pass additional functions as a cell array to be published.
# added '-calltree' opition to the depfun call to find the functions
passed into other functions like ode's and quad.

20 Jan 2012

Changed title

23 Jan 2012

Added support for displaying published html document if no output variable is specified.

23 Jan 2012

Added support for displaying published html document if no output variable is specified.

13 Feb 2012

added ability to remove mex files from output

05 Feb 2013

added ability to add user list of functions that are not to be published

Contact us