Skip to content

Instantly share code, notes, and snippets.

@bttmly
Created February 26, 2016 04:36
Show Gist options
  • Save bttmly/605c487ae72781ed17a6 to your computer and use it in GitHub Desktop.
Save bttmly/605c487ae72781ed17a6 to your computer and use it in GitHub Desktop.
parse the nba_py docs into an array of endpoint descriptions that can be used to dynamically construct an API client
// targets this file: https://github.com/seemethere/nba_py/wiki/stats.nba.com-Endpoint-Documentation
var fs = require("fs");
var markdown = fs.readFileSync("./stats.nba.com-Endpoint-Documentation.md", "utf8");
function createDescription (block) {
var name = block[0].slice(3, -1);
var params = block.slice(2).map(line => line.slice(4)).filter(Boolean);
return {name, params};
}
var endpoints = markdown
.split("\n\n")
.map(block => block.split("\n"))
.filter(block => block[0].startsWith("##"))
.map(createDescription);
// do something with endpoints...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment