Code covered by the BSD License  

Highlights from
Doctest - embed testable examples in your function's help comments

Doctest - embed testable examples in your function's help comments

by

 

27 Sep 2010 (Updated )

Put a usage example in the help of your function, then test it to make sure it still works over time

gen_readme.m
% To generate .../doctest/README.html, 
% change directory to .../doctest/doc
% then run gen_readme
% 
% Then in the shell run html2markdown.py README.html > README.markdown
%

opts = [];
opts.format = 'html';
opts.outputDir = '..';
opts.showCode = false;

publish('README', opts);

% Convert HTML to ReStructuredText
% Using Pandoc, a document converter
% http://johnmacfarlane.net/pandoc/

! pandoc -o ../README.almost.rst ../README.html
! sed -e 's/<#\(.\+\)>/<#id\1>/' ../README.almost.rst > ../README.rst
! rm ../README.almost.rst


% % To convert to Markdown, do this:
% if ~ exist('html2text.py', 'file')
%     ! wget http://www.aaronsw.com/2002/html2text/html2text.py
%     ! chmod a+rx html2text.py
% end
% 
% ! ./html2text.py ../README.html > ../README.markdown
% 

Contact us