Commit 71be665e authored by Paul Asmuth's avatar Paul Asmuth
Browse files

update documentation, simplify 'linecharts/explicit_domain' example

parent 98038164
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -10,8 +10,6 @@ plot {
  axis-y-min: -30;
  axis-y-max: 40;

  margin-right: 2.4em;

  layer {
    type: lines;
  }
+119 −119

File changed.

Preview size limit exceeded, changes collapsed.

+49 −22
Original line number Diff line number Diff line
@@ -2,45 +2,46 @@
import xml.etree.ElementTree as ET
import pystache as TPL
from build_layout import *
import markdown
import yaml

def build_prop(parent):
def build_prop_overview(parent):
  tpl = """
    <section class="api_ref">
      {{{elem_name}}}
      <table>
        <tbody>
      <div class="plist">
        {{#props}}
            <tr>
              <td width="35%"><code><strong>{{name}}</strong></code></td>
              <td>{{desc}}</td>
            </tr>
          <a href="/reference/{{scope}}/{{name}}" class="prop">
            <span><code><strong>{{name}}</strong></code></span>
            <span>{{desc}}</span>
          </a>
        {{/props}}
        </tbody>
      </table>
      </div>
    </section>
  """

  if parent.attrib["path"] == "global":
  if parent["path"] == "global":
    elem_name = "<h2>Global Properties</h2>"
  else:
    elem_name = TPL.render(
        "<h2>Element <code>{{name}}</code></h2>",
        {
          'name': parent.attrib["path"]
          'name': parent["path"]
        })

  if "cond" in parent.attrib:
  if "cond" in parent:
    elem_name += TPL.render(
        "<h2 class=sub>where <code>{{cond}}</code></h2>",
        {
          'cond': parent.attrib["cond"]
          'cond': parent["cond"]
        })

  props = []
  for prop in parent.findall("./prop"):
  for prop in parent["properties"]:
    props.append({
      "name": prop.attrib["name"],
      "desc": prop.attrib["desc"] if "desc" in prop.attrib else "",
      "scope": parent["id"],
      "name": prop["name"],
      "desc": prop["desc_short"] if "desc_short" in prop else "",
    })

  return TPL.render(tpl, {
@@ -48,13 +49,39 @@ def build_prop(parent):
    "elem_name": elem_name
  })

def build_prop_detail(parent, prop):
  url = parent["id"] + "/" + prop["name"]
  print("> Building page: /reference/%s" % url)

  print(prop)
  title = "%s | %s | API Reference" % (prop["name"], parent["path"])
  tpl = Path("extra/web/reference_detail.tpl.html").read_text()
  path = "/reference/" + url
  env = {
    "name": prop["name"],
    "description": markdown.markdown(prop.get("desc", prop["desc_short"])),
    "demo": prop.get("demo", ""),
    "syntax_formal": prop.get("syntax_formal", ""),
    "syntax_example": prop.get("syntax_example", ""),
    "values": prop.get("values", []),
    "default": markdown.markdown(prop.get("default", "")),
    "scope": markdown.markdown(prop.get("scope", "")),
    "scope_example": prop.get("scope_example", ""),
  }

  html = TPL.render(tpl, env)
  write_page(path, html, title=title)

def main():
  tree = ET.parse('manual/properties.xml')
  root = tree.getroot()
  tree = yaml.load(open('manual/properties.yml'))
  html = ""

  for prop in root.findall("./elem"):
    html += build_prop(prop)
  print(tree)
  for elem in tree["elements"]:
    html += build_prop_overview(elem)

    for prop in elem["properties"]:
      build_prop_detail(elem, prop)

  tpl = """
    <h1>API Reference</h1>
+3 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ tpl = """
    <title>{{title}} | plotfx</title>
    <link href='/documentation.css' type='text/css' rel='stylesheet' />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,700" rel="stylesheet">
    <meta name="google-site-verification" content="YeeIR81CPKSaRurQUh6j82N5tH5lcNXTsdqBICkNpyU" />
    <meta name="google-site-verification" content="GxeOO-JtsPc9Doi_WQTvQFI-b7TQgCYxjsVTNtsA7Rc" />
  </head>
  <body>
    <div id="header" class="border">
+62 −9
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ html {
body {
  margin: 0;
  padding: 0;
  font-family: Helvetica, Arial, sans-serif;
  font-family: "Roboto", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 20px;
  background-color: #fff;
@@ -47,6 +47,19 @@ h2 {
  font-weight: 600;
}

h3.section {
  font-size: 19px;
  margin-top: 2em;
  margin-bottom: 1em;
  border-bottom: 1px solid #ddd;
  font-weight: 500;
}

section {
  border-top: 1px solid #ddd;
  margin-bottom: 2em;
}

hr {
  border:none;
  border-top: 1px solid #222;
@@ -212,9 +225,9 @@ ul li p {

#documentation {
  flex: 1;
  color: #444;
  color: #000;
  background: #fff;
  font-size: 16px;
  font-size: 14.5px;
  font-weight: 400;
  margin: 0;
  padding: 16px 0 50px 0;
@@ -224,7 +237,7 @@ ul li p {
#documentation h1 {
  margin-bottom: 0.6em;
  padding-bottom: 0;
  font-size: 30px;
  font-size: 28px;
  font-weight: 500;
}

@@ -246,8 +259,12 @@ ul li p {
  margin-top: 1em;
}

#documentation pre + h3 {
  margin-top: 2em;
#documentation h3 + pre {
  margin-top: 0.2em;
}

#documentation pre + h3.section {
  margin-top: 1.8em;
}

#documentation p {
@@ -255,11 +272,11 @@ ul li p {
  margin-bottom: .6em;
  font-weight: 400;
  line-height: 22px;
  color: #444;
  color: #000;
}

#documentation p, #documentation li, #documentation td, #documentation th {
  line-height: 155%;
  line-height: 150%;
}

#documentation hr {
@@ -372,6 +389,19 @@ table.invisible tr, table.invisible td {
  padding-left: 2em;
}

#documentation dl {
  margin-top: 0;
  margin-bottom: 2em;
}

#documentation dl dt {
  margin-top: 1em;
}

#documentation dl dt:first-child {
  margin-top: 0;
}

#documentation .api_ref {
  border: 1px solid #ddd;
  margin-top: 2em;
@@ -404,9 +434,32 @@ table.invisible tr, table.invisible td {
  line-height: 16pt;
}

#documentation .api_ref table {
#documentation .api_ref .plist {
  display: table;
  border-top: 2px solid #ddd;
  margin-top: .6em;
  margin-bottom: 0;
  width: 100%;
}

#documentation .api_ref .prop {
  display: table-row;
  width: 100%;
  color: inherit;
}

#documentation .api_ref .prop:nth-child(2n+0) { background-color: #f8f8f8; }

#documentation .api_ref .prop:hover {
  background: #00f;
  color: #fff;
  text-decoration: none;
}

#documentation .api_ref .prop > span {
  display: table-cell;
  padding: 6px 6px 5px 6px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #eee;
}
Loading