Torch Documentation Template

This template allows you to document your Torch package using Github Flavoured Markdown, and automatically generate nicely styled HTML with automatic table of content, to be distributed along with the source and published online.

Examples

Four live examples:

Add to your package

Pre-requisites

Merge this template in your repository

From the root of your repository, in the master branch:

git remote add template https://www.github.com/jucor/torch-doc-template
git fetch template
git merge -X ours template

This will create a folder doc/src, that you can edit, and doc/html, that will be automatically built by Jekyll and that you will then publish.

Generate HTML

After editting your Markdown files in doc/src, you need to convert it to HTML locally, with automatic Table of Contents, styles and layouts, using Jekyll:

cd doc/src
bundle exec jekyll build --destination ../html

Your users can now browse your documentation with their browser, opening [doc/src/index.html], and you can distribute it along with your package.

Optional but convenient: while you edit, Jekyll can dynamically build your pages, refresh them, and serve them to http://localhost:4000:

cd doc/src
bundle exec jekyll serve --destination ../html --watch

Publish on Github Pages

It is recommended to have the pages published online, too. If your project is on Github, using Github Pages facility is easy.

Note: even though Github Pages runs a version of Jekyll on their server, it forbid plugins, i.e. no automatic Table of Contents, and would not allow you to distribute the HTML rendering of your documentation along with your source for local browsing. This is why this template recommends to use your own Jekyll locally and only push HTML pages to GH-Pages.

First time only: create gh-pages branch

Create a branch named gh-pages, where Github Project Pages for content. The git subtree command moves all files from doc/html to the root of the gh-pages branch.

git subtree split --prefix doc/html --branch gh-pages

Merge and push online

Now, everytime you have modified doc/src, updated locally the doc/html with Jekyll, and committed both to your master branch, you just:

  1. Commit to your master branch the changes you just made:

    git commit -a -m "Regenerate HTML pages"
    
  2. Update the gh-pages with only the HTML part, automatically moved to the root, by:

    git checkout gh-pages
    git merge -X theirs -X subtree=doc/html master
    
  3. And push online:

    git push -u origin gh-pages
    

Your files will now be accessible at http://yourlogin.github.io/yourrepository.

Personalize

To modify your documentation:

Going further