Commit fc36c1d2 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

build simple example index

parent 288510ca
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ and fun.
on removing the old SQL chart specification language and replacing it with the
new CSS-like syntax. This might take a while...

[Examples](https://github.com/plotfx/plotfx/tree/master/examples) |
[Documentation](https://plotfx.org/)
[Examples](https://plotfx.org/examples) |
[Documentation](https://plotfx.org/reference)


Getting Started
@@ -32,7 +32,7 @@ Here is how to create a simple line chart using plotfx:

Output File (`example_chart.svg`):

[![A simple line chart](./examples/linecharts/lines_with_points.svg)](./examples/linecharts/lines_with_points.ptx)
[![A simple line chart](https://plotfx.org/examples/linecharts/lines_with_points)](./examples/linecharts/lines_with_points.ptx)

Input File (`example_chart.ptx`):

@@ -59,7 +59,7 @@ Input File (`example_chart.ptx`):
    }


For more examples, please see [the examples page](https://github.com/plotfx/plotfx/tree/master/examples).
For more examples, please see [the examples page](https://plotfx.org/examples).


Building
@@ -117,7 +117,7 @@ Here are some more examples of plots generated by PlotFX:
</table>


For more examples, please see [the examples page](https://github.com/plotfx/plotfx/tree/master/examples).
For more examples, please see [the examples page](https://plotfx.org/examples).


Acknowledgements
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ fi

cp extra/web/documentation.css "${output_dir}"
./extra/web/build_api_reference.py
./extra/web/build_examples.py
./extra/web/build_pages.py
find "${output_dir}" -name "_*" -delete
+46 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
import pystache as TPL
from glob import glob

from build_layout import *
from pathlib import Path

def build_example(url):
  print("> Building page: /examples/%s" % url)

  tpl = Path("manual/example.tpl.html").read_text()
  path = "/examples/" + url
  env = {
    "example_url": url,
    "example_src": Path(os.path.join("examples", url + ".ptx")).read_text(),
  }

  html = TPL.render(tpl, env)
  write_page(path, html)
  copy_file(path + "/output.svg", os.path.join("examples", url + ".svg"))

def build_example_list(examples):
  tpl = """
    <ul>
      {{#list}}
        <li><a href="/examples/{{name}}">{{name}}</a></li>
      {{/list}}
    </ul>
  """
  env = {
    "list": map(lambda x: { "name": x }, examples)
  }

  write_file("/_example_list.gen.html", TPL.render(tpl, env))

def main():
  examples = []
  for example in glob("examples/**/*.ptx", recursive=True):
    examples.append(os.path.splitext(os.path.relpath(example, "examples"))[0])

  for example in examples:
    build_example(example)

  build_example_list(examples)

main()
+5 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ import pystache as TPL
import yaml
import os
from pathlib import Path
from shutil import copyfile

tpl = """
<!DOCTYPE html>
@@ -72,3 +73,7 @@ def write_file(path, content):
  output_dir.mkdir(parents=True, exist_ok=True)
  with open(output_path, "w+") as f:
    f.write(content)

def copy_file(path, src_path):
  output_path = os.environ["output_dir"] + path
  copyfile(src_path, output_path)
+1 −4
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ from build_layout import *
import yaml
import markdown
from pathlib import Path
from mdx_gfm import GithubFlavoredMarkdownExtension
import re

def build_page(page):
@@ -16,9 +15,7 @@ def build_page(page):
  else:
    source = "file not found"

  html = markdown.markdown(
      source,
      extensions=[GithubFlavoredMarkdownExtension()])
  html = markdown.markdown(source)

  html = re.sub(
      r'{%([^%]+)%}',
Loading