From 0233b8559de41513153101a34311aaaa1147a211 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 19 May 2022 22:14:41 +0200 Subject: [PATCH] doc: added some missing docstrings --- src/build/build.v | 1 - src/cron/daemon/daemon.v | 1 - src/models/models.v | 5 +++++ src/util/util.v | 9 --------- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/build/build.v b/src/build/build.v index 1f26d03..16942bd 100644 --- a/src/build/build.v +++ b/src/build/build.v @@ -4,7 +4,6 @@ import docker import encoding.base64 import time import os -import db import strings import util import models { GitRepo } diff --git a/src/cron/daemon/daemon.v b/src/cron/daemon/daemon.v index e92dd68..82c219d 100644 --- a/src/cron/daemon/daemon.v +++ b/src/cron/daemon/daemon.v @@ -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 } diff --git a/src/models/models.v b/src/models/models.v index a32ae39..924f45f 100644 --- a/src/models/models.v +++ b/src/models/models.v @@ -1,5 +1,7 @@ module models +// from_params creates a new instance of T from the given map by parsing all +// of its fields from the map. pub fn from_params(params map[string]string) ?T { mut o := T{} @@ -8,6 +10,8 @@ pub fn from_params(params map[string]string) ?T { return o } +// patch_from_params updates the given T object with the params defined in +// the map. pub fn patch_from_params(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(mut o T, params map[string]string) ? { } } +// params_from converts a given T struct into a map of strings. pub fn params_from(o &T) map[string]string { mut out := map[string]string{} diff --git a/src/util/util.v b/src/util/util.v index f9d47a8..266bcb5 100644 --- a/src/util/util.v +++ b/src/util/util.v @@ -64,12 +64,3 @@ pub fn pretty_bytes(bytes int) string { return '${n:.2}${util.prefixes[i]}' } - -pub fn struct_to_map(o T) map[string]string { - mut m := map[string]string{} - - $for field in T.fields { - m[field.name] = o.$(field.name).str() - } - return m -}