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

webdocs: page titles

parent ee96e46c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -13,10 +13,11 @@ def build_example(url):
  env = {
    "example_url": url,
    "example_src": Path(os.path.join("examples", url + ".ptx")).read_text(),
    "title": "Example: %s" % url,
  }

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

def build_example_list(examples):
@@ -28,7 +29,7 @@ def build_example_list(examples):
    </ul>
  """
  env = {
    "list": map(lambda x: { "name": x }, examples)
    "list": map(lambda x: { "name": x }, examples),
  }

  write_file("/_example_list.gen.html", TPL.render(tpl, env))
+5 −5
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ tpl = """
<!DOCTYPE html>
<html>
  <head>
    <title>plotfx | <%= @title || "Collect and visualize timeseries data with SQL" %></title>
    <title>{{title}} | plotfx</title>
    <link href='/documentation.css' type='text/css' rel='stylesheet' />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  </head>
@@ -60,12 +60,12 @@ tpl = """
</html>
"""

def build_layout(url, content):
def build_layout(url, content, title=""):
  toc = yaml.load(Path("manual/toc.yaml").read_text())["documentation"]
  return TPL.render(tpl, {"content": content, "url": url, "toc": toc})
  return TPL.render(tpl, {"content": content, "url": url, "toc": toc, "title": title})

def write_page(url, content):
  write_file(url + "/index.html", build_layout(url, content))
def write_page(url, content, title=""):
  write_file(url + "/index.html", build_layout(url, content, title=title))

def write_file(path, content):
  output_path = os.environ["output_dir"] + path
+2 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ def build_page(page):
  print("> Building page: %s" % page["url"])
  url = page["url"]
  path = "manual/" + page["file"] + ".md"
  title = page.get("doctitle", page["title"])

  if os.path.isfile(path):
    source = Path(path).read_text()
@@ -22,7 +23,7 @@ def build_page(page):
      lambda m: Path(os.path.join(os.environ["output_dir"], m[1])).read_text(),
      html)

  write_page(url, html)
  write_page(url, html, title=title)

def build_toc(toc):
  for page in toc:
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ documentation:
    pages:
      -
        title: "Introduction"
        doctitle: "PlotFX - The open-source plotting toolkit"
        url: "/"
        file: "introduction"
      -