Examples

This page shows six complete sites of the folder examples/, each with its files and a picture of its start page. CI builds each one with -strict and compares the output with tests/expected/, so each example on this page works with this version.

Build an example with:

flight-manual build -strict -site examples/NAME/site.fm _site

The pictures come from tools/example-shots.sh, which builds each example and takes a picture of it in Chromium.

basic: groups of pages and a picture

examples/basic has three pages in two groups, a picture, a table, a note, and code in JSON.

site.fm
docs/
  index.md
  install.md
  guide/first-site.md
  images/square.svg
assets  {docs/images images}
pages {
    group Start
    docs/index.md
    docs/install.md
    group Guide
    docs/guide/first-site.md  guide/first-site/  "A first site"
}

The start page of the example basic, with the menu in two groups at the left

readme: a site from the README of a project

examples/readme makes a site from README.md and CHANGELOG.md at the top of a project. The README is the start page. The link to src/tally.tcl goes to the file in the repository, because the site file has the key repo.

repo    https://github.com/example/tally
pages {
    README.md        ""          Tally
    CHANGELOG.md     changelog/  Changes
}

The start page of the example readme, with the options in a table

commands: a command reference

examples/commands has one page for each command of a program, each in one form. A page has what the command does, the synopsis, the arguments, an example, and the commands next to it. The start page has a table of the commands.

docs/
  index.md
  commands/on.md
  commands/off.md
  commands/bright.md

The start page of the example commands, with a table of the three commands

api: an API reference from a data file

examples/api makes a page for each function of data/api.json. The plugin api.tcl reads the file in its hook pages and adds a page with its own HTML for each function. The site file gives the plugin allow file, so it can read the data file.

plugins api.tcl
allow   file
proc pages {list} {
    set data [ztcl::json parse [fm::read data/api.json]]
    foreach f [dict get $data functions] {
        ...
        lappend list [dict create src "" page functions/$name/ group Functions \
            label $name body $body description [dict get $f summary]]
    }
    return $list
}

The start page of the example api, with the group Functions in the menu

plugin: a code block of a new kind

examples/plugin has a plugin with two hooks. The hook fence shows a code block with the language tree as a list of files. The hook html adds the link "Edit this page" at the end of each page.

proc fence {page info text} {
    if {[lindex $info 0] ne "tree"} { return "" }
    ...
}

The start page of the example plugin, with a list of files and the link Edit this page

style: a style of its own

examples/style has the style folder look/ with a page template, a style sheet with a light and a dark theme, and an icon. The build checks the contrast of the colors of the style sheet.

site.fm
look/
  page.html
  site.css
  favicon.svg

The start page of the example style, with a dark blue bar at the top and the bottom

Next: Write the pages.