From 3007ab8528a30cac41896e89f83ecd80e3954866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Sun, 23 Apr 2023 15:32:17 +0200 Subject: [PATCH] Split mbase documentation. --- doc/mbase.md | 459 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/modules.md | 451 ------------------------------------------------ 2 files changed, 459 insertions(+), 451 deletions(-) create mode 100644 doc/mbase.md diff --git a/doc/mbase.md b/doc/mbase.md new file mode 100644 index 0000000..061f40e --- /dev/null +++ b/doc/mbase.md @@ -0,0 +1,459 @@ +Members Base +============ + +These modules manage the member files in members directory. + +Modules +------- + +### Member Record + +This module encapsulates the data structure representing a single +member record. + + (make-member-record file-name file-path symlinks . args) + +* ```file-name``` - a symbol representing the primary filename +* ```file-path``` - a string representing the path to the file +* ```symlinks``` - a list of symbols representing symlinks +* ```args``` - optional keyword arguments + +Creates a new member record dictionary. The three mandatory arguments +are stored under respective keys and any keyword arguments are stored +as keys obtained by converting the keyword to symbol with values +following the keyword. + +The ```'id``` key is filled with any four-digit file-name or symlink +converted to a number. Preferably the four-digit symbol should be the +file-name but it is not required. + + (member-file-path mr) +* ```mr``` - a member record structure + +Returns the path used for accessing this member's file. + + (member-record-input-file mr) + +* ```mr``` - a member record structure + +Returns an open file port to given member record underlying file. This +function should be used by the parser to get the member file contents. + + (member-record-set mr . args) + +* ```mr``` - a member record structure +* ```args``` - optional keyword arguments + +Any keyword arguments are stored in the member record dictionary as +keys obtained by converting the keyword to symbol with values +following the keyword. + + (member-record-add-highlight mr line message pass type) + +* ```mr``` - a member record structure +* ```line``` - line number in the source file +* ```message``` - a string with message for highlight +* ```pass``` - parsing stage +* ```type``` - symbol representing the highlight type + +Adds a new highlight to member record to be used when displaying the +source file listing. + +Known types are: + +* ```'error``` - to denote fatal problem in the source +* ```'warning``` - to signal known problem which does not make the record invalid +* ```'info``` - supplemental information + +The structure is perfectly suited for ```print-source-listing``` function. + + (member-record-sub-ref mr sec key [default]) + +* ```mr``` - a member record structure +* ```sec``` - section symbol +* ```key``` - key symbol +* ```default``` - optional default value + +Retrieves given ```key``` from dictionary stored as section ```sec``` +in given ```mr``` structure. If no ```default``` is provided and the +```key``` does not exist it raises an exception. + + (member-record-sub-set mr sec key value) + +* ```mr``` - a member record structure +* ```sec``` - section symbol +* ```key``` - key symbol +* ```value``` - value to set + +Sets the value of given ```key``` in dictionary stored as section +```sec``` in given ```mr``` structure to the new ```value``` possibly +overwriting previous one. + + (member-record-sub-prepend mr sec key value) + +* ```mr``` - a member record structure +* ```sec``` - section symbol +* ```key``` - key symbol +* ```value``` - value to prepend (cons) to the key current value + +Prepends (cons) new the ```value``` to current value of given ```key``` in +dictionary stored as section ```sec``` in given ```mr``` structure +replacing the original value. + + (member-record-sub-has-key? mr sec key) + +* ```mr``` - a member record structure +* ```sec``` - section symbol +* ```key``` - key symbol + +Returns ```#t``` if given section ```sec``` contains the ```key```. + + (member-record-sub-ensure mr sec key value) + +* ```mr``` - a member record structure +* ```sec``` - section symbol +* ```key``` - key symbol +* ```value``` - value to set + +Sets the value of given ```key``` in dictionary stored as section +```sec``` in given ```mr``` structure to the new ```value``` if and +only if it is not already present. + + (member-source mr) + +* ```mr``` - a member record structure + +Returns a list of strings representing the source file of this member +record. + + (member-record-info mr key [default]) + +* ```mr``` - a member record structure +* ```key``` - key (symbol) to retrieve +* ```default``` - optional default value + +Like ```dict-ref``` returns the value associated with ```key``` in +section ```'info```. If ```default``` is provided, it is passed on to +the underlying ```dict-ref```. + + (member-missing-keys mr) + +* ```mr``` - a member record structure + +Returns a list of keys (symbols) from within the ```'info``` section +of given ```mr``` that have ```#f``` values (indicating they are +missing mandatory fields in the source). + + (member-has-highlights? mr) + +* ```mr``` - a member record structure + +Returns ```#t``` if given ```mr``` has at least one source highlight. + + (member-record-usable? mr) + +* ```mr``` - a member record structure + +Returns ```#t``` if it is possible to work with this member - mainly +that the ```'info``` section contains the ```'member``` key. + + (member-has-problems? mr) + +* ```mr``` - a member record structure + +Returns ```#t``` if there are any ```'error``` type highlights in +```mr```, or it is not ```member-record-usable?``` or the +```member-id``` is not 4-digit prime number. + + (member-destroyed? mr) + +* ```mr``` - a member record structure + +Returns ```#t``` if the member is not existing and already has existed +in the past. + + (member-suspended? mr) + +* ```mr``` - a member record structure + +Returns ```#t``` if the current month falls within any of given member's +suspended periods. + + (member-active? mr) + +* ```mr``` - a member record structure + +Returns ```#t``` if given member exists, is a member and is currently +not suspended. + + (member-student? mr) + +* ```mr``` - a member record structure + +Returns ```#t``` if given member exists, is a member, is currently not +suspended and current month falls within any member's suspended +periods. + + (member-existing? mr) + +* ```mr``` - a member record structure + +Returns ```#t``` if given member exists - that is the current month is +within any of the member (membership) periods. + + (member-flags mr) + +* ```mr``` - a member record structure + +Returns a list of member flags which can be any of the following: + +* ```'student``` +* ```'suspended``` +* ```'active``` +* ```'destroyed``` +* ```'existing``` + +The ```'existing``` and ```'destroyed``` are mutually exclusive. Also +```'active``` and ```'suspended``` are mutually exclusive. + + (member-nick mr) + +* ```mr``` - a member record structure + +Returns member's nick from its ```'info``` section. + + (member-id mr) + +* ```mr``` - a member record structure + +Returns given member's id. + + (member-suspended-months mr) + +* ```mr``` - a member record structure + +Returns the number of months this member is suspended in +```(*current-month*)```. If the member is not suspended, returns +```0```. + + (member-format fmt mr) + +* ```fmt``` - format string +* ```mr``` - a member record structure + +Fills the following template substitutions in the ```fmt``` string: + +* ```~N``` - member's nick +* ```~I``` - member's id +* ```~S``` - number of months this member has been suspended +* ```~E``` - number of highlights in square brackets if there is at least one +* ```~~``` - literal ```~``` + +Other parts of the string are retained. + + (member