Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

publish depfun in separate files, split by code sections

Asked by Christoph on 2 Apr 2013

I have created a program that consists of several (100+) functions which are each called from one main routine file. I would like to create an html-based documentation in which the user can navigate through the functions by clicking on links of the called and the calling functions for each function, starting from the main routine file.

I am aware that there exists the function publishdepfun that should be possible to modify in order to obtain the desired result. Essentially, I will have to create separate output files (next to the appended full file), replace the in-document hyperlinks under ‘Called functions’ with full-path hyperlinks and add a section for calling functions. Additionally, it would be great if the called functions could be split along the sections of the calling function – I’ll try to illustrate:

The report for the main function would look like this (imagine the formatting of the documentation reports here, I don’t know how to generate these in the question tool):

mainRoutine

Calls all other routines

Calls:

  • Load
  • Compute
  • Save

Other comments…

Where load, compute and save are hyperlinks. Following the one of the links then should lead to the report page:

Load

Loads data from various data sources to workspace

Called in:

mainRoutine

Contents:

  • LoadRawData
  • Transform

LoadRawData:

Loads raw data from external sources

Calls:

  • loadDataSourceA
  • loadDataSourceB

Transform:

Transforms data formats from external sources to data format used in the program

Calls:

  • transformDataFromSourceA2DataFormatUsed
  • transformDataFromSourceB2DataFormatUsed

So the called functions are split by sections, instead of having two separate hierarchies like this (what the publishdepfun creates automatically):

Load

Loads data from various data sources to workspace

Called in:

  • mainRoutine

Contents:

  • LoadRawData
  • Transform

Calls:

  • loadDataSourceA
  • loadDataSourceB
  • transformDataFromSourceA2DataFormatUsed
  • transformDataFromSourceB2DataFormatUsed

_ LoadRawData:_

Loads raw data from external sources

_ Transform:_

Transforms data formats from external sources to data format used in the program

I do not know how to tackle the splitting by sections, so if you have any ideas I would be very grateful! Additionally, if you know a function similar to publishdepfun that creates the mentioned output (also without splitting by sections) this would be very much appreciated as it would save me the effort of modifying it.

0 Comments

Christoph

Products

No products are associated with this question.

1 Answer

Answer by per isakson on 2 Apr 2013
Edited by per isakson on 2 Apr 2013

3 Comments

Christoph on 3 Apr 2013

Thanks for the links! I had a look at M2HTML and makehtmldoc. As for M2HTML I just wanted to point out that all links to the Matlab file exchange are broken, it seems to have been removed. I managed to download a copy from the website, but the code had some strange issues (like calling fopen with an undefined permission flag 'rt'...) which I had to fix before the function would even run without crashing. I can see a glimpse of the output now, even though the formatting and images don’t work yet. Anyway, I get the idea of what it should look like and it does seem interesting, though a bit bloated for my purposes (I tested it with one file without dependencies and it produced 22 output files, most of which tiny images). Makehtmldoc on the other hand seems nice and lean, but I don’t see much added value above the built-in publish function.

I am actually quite happy with what the publish function does, and I would just like to embellish it by adding call dependencies and splitting along sections. I think the call dependencies will be manageable, but I am still looking for an idea for how to produce the splitting along sections as described in the original post. Is there any way to retrieve the information in which section a function is called from a function like depfun?

per isakson on 3 Apr 2013

Doc says: fopen [...]To open files in text mode, attach the letter 't' to the permission, such as 'rt' or 'wt+'. [...]

Christoph on 3 Apr 2013

So true, I should have read the doc further - my bad! I fixed everything back, the routine does run nicely now. I'll see if I can use it or whether I'll just go and make an adapted version of publishdepfun...

per isakson

Contact us