docs
docs copied to clipboard
Extract code samples from the docs repo, with markers
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.
Implemented in PR #50