Galleries and screenshots
A card for each sample program of a folder, with the screenshot of its window, its comment, the command to run it and its source.
The gallery directive#
A page has one line:
{{gallery:samples}}and the project file describes the gallery called samples in :galleries:
:galleries = [
[ :name = "samples", :folder = "samples", :prefix = "hello-", :run = "ring samples/{file}" ]
]Each card has the name of the sample (made from the file name: 02_color_wheel.ring is "Color wheel"), the comment at the top of the file as the description, the command, and the source in a folded block. Without a screenshot the card shows "no screenshot".
The keys of a gallery#
| Key | Meaning |
|---|---|
:name | the name used by {{gallery:name}} |
:folder | the folder of the programs, relative to :root |
:layout | "files" (default): the .ring files of the folder; "folders": folder/Name/Name.ring |
:skip | names of files or folders that are not samples |
:needs | a program is a sample only when its text has one of these words |
:prefix | the screenshot is <output>/<shots>/<prefix><name>.png; :shots of the project is img/shots by default |
:run | the command shown on the card; {file}, {name} and {folder} are replaced |
:args | [ ["name", "--draw"] ]: arguments of a program when it is photographed |
:delays | [ ["name", 3500] ]: milliseconds to wait for the window; :delay (3000) is for the others |
The screenshots#
ringdoc shoot [docproject.ring] [gallery ...] [--missing]starts each program, waits for its window, captures it and closes the program. --missing leaves the samples that have a screenshot already, and gallery names limit the work to those galleries. Then build shows the pictures.
This works on Windows only: the window is captured with the Windows API called through ring-cffi (ringpm install ring-cffi from ysdragon), and the PNG is written by GDI+.
The project may set :ringexe (the Ring interpreter that runs the programs; by default the one that runs ringdoc, or ring/bin/ring for a ringdoc.exe) and :bin (a folder put first in PATH while the programs run).
The galleries of RingDotNet (Windows Forms, WPF, applications, Avalonia: 190 cards) made this way are identical to the pages made by its own tools.