Support documentation refactoring.

This commit is contained in:
Dominik Pantůček 2023-04-13 22:37:44 +02:00
parent 54263d48e1
commit 32adf19033
4 changed files with 78 additions and 61 deletions

View file

@ -12,6 +12,8 @@ much in common.
### ANSI ### ANSI
(import ansi)
A simple module for creating ANSI (ECMA-48) sequence strings. A simple module for creating ANSI (ECMA-48) sequence strings.
(ansi . args) (ansi . args)
@ -123,6 +125,8 @@ corner.
### Command Line parsing ### Command Line parsing
(import command-line)
Generic syntax-based implementation of command-line options parsing Generic syntax-based implementation of command-line options parsing
with focus on generated help and ergonomic binding of option with focus on generated help and ergonomic binding of option
arguments. arguments.
@ -156,6 +160,8 @@ help strings in a nice, human-readable format.
### Listing ### Listing
(import listing)
This module implements listing a text file with line numbers and This module implements listing a text file with line numbers and
optional highlights of given source lines, optionally with comments optional highlights of given source lines, optionally with comments
for those lines. for those lines.
@ -210,6 +216,8 @@ If some lines between highlight and/or context lines are omitted,
### Progress ### Progress
(import progress)
Provides syntax forms and procedures for showing progress of a Provides syntax forms and procedures for showing progress of a
process. process.
@ -275,8 +283,73 @@ progress% value must be updated with ```progress%-advance```.
If the new-value differs from last value shown more than If the new-value differs from last value shown more than
```(*progress%-step*)```, redisplays the current progress%. ```(*progress%-step*)```, redisplays the current progress%.
### Table
(import table)
This module provides moderately complex terminal table rendering.
(*table-border-style* [style])
* ```style``` - symbol representing the style
Valid styles are:
* ```'debug``` - special style to see any rendering problems
* ```'ascii``` - plain ASCII (7-bit)
* ```'unicode``` - nice box-drawing table (UTF-8)
If invalid style is provided, ```'debug``` style is automatically
substituted.
(table->string tbl
[#:table-border #f]
[#:row-border #f]
[#:col-border #f]
[#:row0-border #f]
[#:col0-border #f]
[#:border-style (*table-border-style*)]
[#:ansi #f])
* ```tbl``` - list of lists with cell data
* ```#:table-border``` - if ```#t```, the table has outer border
* ```#:row-border``` - if ```#t```, the rows are separated by borders
* ```#:col-border``` - if ```#t```, the columns are separated by borders
* ```#:row0-border``` - if ```#t```, the first row is separated by border
* ```#:col0-border``` - if ```#t```, the first column is separated by border
* ```#:border-style``` - which border style to use (see
```*table-border-style*``` which is the default)
* ```#:ansi``` - if ```#t```, all cell line strings are terminated
with ```a:default```
The table ```tbl``` is represented as a list of rows where each row is
a list of cells that hold arbitrary values that are converted to
string when rendering the table.
Before rendering the table, the following steps are performed:
* The table is made rectangular - that is all rows are extended by
empty strings to have the same length.
* All non-string cells are converted to string using ```sprintf```
* All cells are split into list of strings representing the lines of
text inside them.
* For each row, all cells are extended by empty strings to have
matching number of lines of text inside them.
* For each column, all lines of text inside all of the cells are
padded with spaces to have uniform width.
Then each table row is converted to list of strings adding column
separators and table borders as required. These lists are then joined
with row separators and possibly prefixed and suffixed by top and
bottom table border.
The resulting list of strings is joined with newline character as the
separator.
### Testing ### Testing
(import testing)
This module provides simple syntax forms for (unit) testing of other This module provides simple syntax forms for (unit) testing of other
modules. modules.
@ -347,65 +420,4 @@ exception. An exception is raised if no exception was raised during
the evaluation. If the test passes, prints "." like all tests from the evaluation. If the test passes, prints "." like all tests from
this module do. this module do.
### Table
This module provides moderately complex terminal table rendering.
(*table-border-style* [style])
* ```style``` - symbol representing the style
Valid styles are:
* ```'debug``` - special style to see any rendering problems
* ```'ascii``` - plain ASCII (7-bit)
* ```'unicode``` - nice box-drawing table (UTF-8)
If invalid style is provided, ```'debug``` style is automatically
substituted.
(table->string tbl
[#:table-border #f]
[#:row-border #f]
[#:col-border #f]
[#:row0-border #f]
[#:col0-border #f]
[#:border-style (*table-border-style*)]
[#:ansi #f])
* ```tbl``` - list of lists with cell data
* ```#:table-border``` - if ```#t```, the table has outer border
* ```#:row-border``` - if ```#t```, the rows are separated by borders
* ```#:col-border``` - if ```#t```, the columns are separated by borders
* ```#:row0-border``` - if ```#t```, the first row is separated by border
* ```#:col0-border``` - if ```#t```, the first column is separated by border
* ```#:border-style``` - which border style to use (see
```*table-border-style*``` which is the default)
* ```#:ansi``` - if ```#t```, all cell line strings are terminated
with ```a:default```
The table ```tbl``` is represented as a list of rows where each row is
a list of cells that hold arbitrary values that are converted to
string when rendering the table.
Before rendering the table, the following steps are performed:
* The table is made rectangular - that is all rows are extended by
empty strings to have the same length.
* All non-string cells are converted to string using ```sprintf```
* All cells are split into list of strings representing the lines of
text inside them.
* For each row, all cells are extended by empty strings to have
matching number of lines of text inside them.
* For each column, all lines of text inside all of the cells are
padded with spaces to have uniform width.
Then each table row is converted to list of strings adding column
separators and table borders as required. These lists are then joined
with row separators and possibly prefixed and suffixed by top and
bottom table border.
The resulting list of strings is joined with newline character as the
separator.
### Environment ### Environment

View file

@ -29,6 +29,7 @@
ansi ansi
( (
ansi ansi
a:error a:error
a:warning a:warning
a:success a:success
@ -36,6 +37,7 @@
a:default a:default
a:muted a:muted
a:highlight a:highlight
ansi-string-length ansi-string-length
ansi-paragraph-format ansi-paragraph-format
ansi-string ansi-string

View file

@ -29,8 +29,10 @@
command-line command-line
( (
command-line command-line
command-line:parse-command-line command-line:parse-command-line
command-line:print-options command-line:print-options
command-line-tests! command-line-tests!
) )

View file

@ -29,6 +29,7 @@
listing listing
( (
print-source-listing print-source-listing
listing-tests! listing-tests!
) )