Name: data-science-examples
Owner: H2O.ai
Description: A collection of data science examples implemented across a variety of languages and libraries.
Created: 2015-12-14 03:46:44.0
Updated: 2018-04-23 13:46:29.0
Pushed: 2016-01-14 19:54:13.0
Homepage: null
Size: 432
Language: CSS
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
View this site in GitHub Pages: http://h2oai.github.io/data-science-examples/
Goal: To provide a side-by-side framework for adding code examples in many different environments
Goal: It should be easy to add an example
Goal: Encourage lots of different people to add an example
Goal: It should be easy to add a new kind of example
Goal: Examples should be testable
Goal: Provide a library of runnable and easy-to-access answers to common questions
Goal: It should be possible to cut-and-paste a “stable” link for a given example
Goal: Provide support for tags
The gen.py tool creates the result examples.html file. (Look at the trivial Makefile.)
I installed the markdown tool on my Macbook Pro with the following command:
install markdown-to-html -g
On Macbook Pro:
add examples.html
commit
push
README.md
This file.
Makefile
Very simple helper for running the generation process.
./gen.py
Tool to generate examples.html.
examples
The example code. New files generally want to go somewhere in here.
examples.html
Generated from files in the examples directory.
data
Data used by examples.
index.html
What gh-pages points to.
packages
Some helper packages used by the examples (ex package for R).
static
Static resources (jquery, bootstrap, highlight.js).
Usually this is as easy as just dropping in one more file with the right name that gen.py knows to look for. You need to add that file in the one specific already-existing example directory. No metadata files need to be updated.
Unless you want to add a totally new kind of example, in which case read on…
gen.py has the following three arrays. (The names are named weirdly to satisfy PEP-8 and still visually line up nicely.)
_lang__________ = ["lang-r", "lang-r"]
_tabs_to_check_ = ["R", "h2o-R"]
_files_to_check = ["ex-R.R", "ex-h2o.R"]
Adding a new kind of example means adding an element to each of these arrays.
Create a new directory. The name of the directory is not used for any of the generated output.
Add your new directory to the 'idx' file of the category that contains it.
Add a 'ex.txt' file in your new directory. This is one line that contains the example name.
Add a 'ex.md' file in your new directory. This is a markdown file that describes the example. For consistency with the generated code from gen.py, this should not include H1, H2 or H3 tags. This may include H4, H5, H6 tags.
The example description markdown file 'ex.md' is converted to html using the node markdown tool.
Optionally create an 'ex.tags' file with one tag per line. Tags may include lower-case letters, numbers, underscores, and spaces.
Create a single code file for each kind of example you want to provide.
ex-R.R
ex-h2o.R
… etc.
Code example files are copied verbatim into the generated examples.html.
The names of the code example files must match exactly what gen.py expects.
The ex R package has a locate function which you may find helpful.
Create a new directory. The name of the directory is not used for any of the generated output.
Add your new directory to the idx file of the category that contains it.
Add a 'cat.txt' file in your new directory. This is one line that contains the category name.
Add an 'idx' file in your new directory. 'idx' is a multi line file. each line contains the name of a directory. each directory is either a sub-category or an example. items appear in the order they are included in the idx file.
Note that the top-level category (Data Science Examples) is special and generally ignored by gen.py so that “Data Science Examples” isn't repeated all over the place.
Testing will be driven by a jenkins job that makes some assumptions.
Other do's and dont's:
I did this with RStudio… TODO: Need better instructions here.