doc: added some missing docstrings

hash-on-upload
Jef Roosens 2022-05-19 22:14:41 +02:00
parent 2fc25f1afe
commit 0233b8559d
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
4 changed files with 5 additions and 11 deletions

View File

@ -4,7 +4,6 @@ import docker
import encoding.base64
import time
import os
import db
import strings
import util
import models { GitRepo }

View File

@ -7,7 +7,6 @@ import cron.expression { CronExpression, parse_expression }
import math
import build
import docker
import db
import os
import client
import models { GitRepo }

View File

@ -1,5 +1,7 @@
module models
// from_params<T> creates a new instance of T from the given map by parsing all
// of its fields from the map.
pub fn from_params<T>(params map[string]string) ?T {
mut o := T{}
@ -8,6 +10,8 @@ pub fn from_params<T>(params map[string]string) ?T {
return o
}
// patch_from_params<T> updates the given T object with the params defined in
// the map.
pub fn patch_from_params<T>(mut o T, params map[string]string) ? {
$for field in T.fields {
if field.name in params && params[field.name] != '' {
@ -26,6 +30,7 @@ pub fn patch_from_params<T>(mut o T, params map[string]string) ? {
}
}
// params_from<T> converts a given T struct into a map of strings.
pub fn params_from<T>(o &T) map[string]string {
mut out := map[string]string{}

View File

@ -64,12 +64,3 @@ pub fn pretty_bytes(bytes int) string {
return '${n:.2}${util.prefixes[i]}'
}
pub fn struct_to_map<T>(o T) map[string]string {
mut m := map[string]string{}
$for field in T.fields {
m[field.name] = o.$(field.name).str()
}
return m
}