matlab2github
: easily convert your docstrings to (GitHub Flavored) Markdown
And easily host them on GitHub pages without downloading any more software!
Getting started
- Download or clone this repo and add it to your path.
- Add docstrings to your functions (see here for information on formatting docstrings, or use the files in this repo as an example).
- Navigate to the root directory and run
matlab2github
from the Command Window (or runmatlab2github(TARGET_DIRECTORY)
). - Markdown files will be output in
./docs
. These are ready to be pushed to GitHub, and you can easily deploy them using GitHub pages.
Formatting docstrings for GitHub
See here for an example of how output is rendered on GitHub.
This function converts the “docstring” (the first comment in the .m
file) into (GitHub® Flavored) Markdown. This function combines the functionality of MATLAB®’s inbuilt PUBLISH and EXPORT functions, as well as some syntax derived from markdown and GitHub Flavored Markdown. For example, use asterisks for bold (*bold*
) text (MATLAB); underscores for italic (_italic_
) text (MATLAB); 1 or 2 dollar signs for inline or block equations like $e^{i\pi } +1=0$ ($ e^{i \pi} + 1 = 0 $); two spaces at the start of a line for sample code (MATLAB); three spaces at the start of a line for executable code (MATLAB); asterisks and numbers for lists (MATLAB and markdown); backticks for inline code
(markdown).
Formatting docstrings for GitHub Pages
Currently, the outputs from matlab2github
are best suited to simple GitHub Pages templates. For example, the website associated with this repo was auto-generated from the docstrings in the MATLAB functions and the just-the-docs template. See here for information on setting up a page in this manner.