diff --git a/README.md b/README.md index 1e734d17..430085a1 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,8 @@ To learn how to use Pixie for realtime graphics with GPU, check out [Boxy](https `git clone https://github.com/treeform/pixie` to run examples. +Run `nim r tools/gen_readme.nim` to refresh the README snippets. To refresh a documentation image, run its example explicitly, such as `nim r --path:src examples/heart.nim`. Review the visual changes before committing a new PNG. + ### Text nim c -r [examples/text.nim](examples/text.nim) ```nim diff --git a/tools/gen_readme.nim b/tools/gen_readme.nim index 15354893..120c7b8e 100644 --- a/tools/gen_readme.nim +++ b/tools/gen_readme.nim @@ -1,4 +1,4 @@ -import os, osproc, strutils +import os, strutils proc cutBetween(str, a, b: string): string = let @@ -26,7 +26,6 @@ var exampleFiles = [ ] for path in exampleFiles: - discard execCmd("nim c -r " & path) let code = readFile(path) let innerCode = code.cutBetween("image.fill(rgba(255, 255, 255, 255))", "image.writeFile") if innerCode != "": @@ -44,9 +43,13 @@ var readme = readFile("README.md") let at = readme.find("## Examples") if at != -1: - readme = readme[0 .. at] -readme.add("# Examples\n\n") + readme.setLen(at) +readme.add("## Examples\n\n") readme.add("`git clone https://github.com/treeform/pixie` to run examples.\n\n") +readme.add("Run `nim r tools/gen_readme.nim` to refresh the README snippets. " & + "To refresh a documentation image, run its example explicitly, such as " & + "`nim r --path:src examples/heart.nim`. Review the visual changes before " & + "committing a new PNG.\n\n") readme.add(md.join("\n")) writeFile("README.md", readme)