dfuse-io / docs

dfuse documentation
https://docs.dfuse.io
MIT License
27 stars 24 forks source link

Extract code samples from the docs repo, with markers #48

Open abourget opened 4 years ago

abourget commented 4 years ago

We'd like to have markers inside .py, .go, .js example files. Currently, they are in quickstarts/*.

Example:

func main() {
    var prep = "hello"
// DFUSE:BEGIN:quickstart_go_search_eos_section1
    var some = "code"
    var to = "show"
// DFUSE:END:quickstart_go_search_eos_section1
}

We need a preprocessing step, that will crawl all files under quickstarts that contain those DFUSE:BEGIN tags. We ignore the first chars (no matter how they're commented out.., with #, or ;; or // ...)

We build a .json output that we drop in /data/samples.json, looking like:

{"quickstart_go_search_eos_section1": "    var some = \"code\"\n    var to = \"show\""}

In hugo, we can reference these with {{ .Data.samples.quickstart_go_search_eos_section1 | highlight }}

Replace those line numbered samples that extract from the quickstarts right now, with this new method.

dliuproduction commented 4 years ago

Implemented in PR #50