Created
February 26, 2016 04:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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