-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a172cf
commit 2828dcb
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ./private/doc_utils/genIndex | ||
##[ | ||
# Lib | ||
Python standard libraries | ||
porting in nimpylib | ||
]## | ||
genIndexHere() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
import std/macros | ||
import std/strutils | ||
import std/os | ||
|
||
proc nimpylibLibFilter*(t: tuple[kind: PathComponent, path: string]): bool = | ||
t.kind != pcDir and t.kind != pcLinkToDir and | ||
t.path != "index.nim" and | ||
not t.path.endsWith"_impl" and | ||
not t.path.startsWith"n_" | ||
|
||
type PathFilter* = typeof nimpylibLibFilter ## path is relative | ||
|
||
proc indexAsMdStr*(dir: string, filter=nimpylibLibFilter): string = | ||
for t in dir.walkDir(relative=true): | ||
if filter(t): | ||
let | ||
fn = t.path | ||
libn = fn.changeFileExt("") | ||
url = fn.changeFileExt("html") | ||
result.add "- [$#]($#)\n".format(libn, url) | ||
|
||
|
||
macro genIndexHere*(filter: static[PathFilter] = nimpylibLibFilter) = | ||
newCommentStmtNode indexAsMdStr(getProjectPath(), filter) |