hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 1513c82824edd42abeabdbf6b8b56396fa1a5db4
parent c2f0840a0ba79b36f4f03aa41cf31efce57821ab
Author: Sebastian <sebastian@sebsite.pw>
Date:   Tue, 17 Oct 2023 22:30:12 -0400

haredoc: only show undocumented submodules with -a

Implements: https://todo.sr.ht/~sircmpwn/hare/801
Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mcmd/haredoc/doc/util.ha | 11++++++++---
Mcmd/haredoc/main.ha | 2+-
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/cmd/haredoc/doc/util.ha b/cmd/haredoc/doc/util.ha @@ -7,6 +7,7 @@ use hare::module; use io; use memio; use os; +use path; use sort; use sort::cmp; use strings; @@ -26,15 +27,19 @@ fn trim_comment(s: str) str = { return strings::dup(memio::string(&trimmed)!); }; -export fn submodules(path: str) ([]str | error) = { +export fn submodules(path: str, show_undocumented: bool) ([]str | error) = { let submodules: []str = []; let it = os::iter(path)?; defer fs::finish(it); + let pathbuf = path::init(path)!; for (true) match (module::next(it)) { + case let d: fs::dirent => + path::set(&pathbuf, path, d.name, "README")!; + if (show_undocumented || os::exists(path::string(&pathbuf))) { + append(submodules, strings::dup(d.name)); + }; case void => break; - case let d: fs::dirent => - append(submodules, strings::dup(d.name)); }; sort::sort(submodules, size(str), &cmp::strs); return submodules; diff --git a/cmd/haredoc/main.ha b/cmd/haredoc/main.ha @@ -208,7 +208,7 @@ fn doc(name: str, cmd: *getopt::command) (void | error) = { }; const submods: []str = if (!ambiguous && modpath != "") { - yield match (doc::submodules(modpath)) { + yield match (doc::submodules(modpath, show_undocumented)) { case let s: []str => yield s; case doc::error =>