## This program fixes the documentation putting the types in each module. ## At the moment, all types are in types.nim to allow cyclic definitions, ## and all members are public to allow access in the appropriate modules. ## ## We signal that we want to move types with the TYPES type, like this: ## ## when defined(nimdoc): ## type TYPES* = MyType1 | MyType2 | MyType3 ## ## Furthermore, we hide all members that have "## private" in their docs. ## ## All of this is a hacky workaround that we hope won't be necessary ## in the future. ## ## Usage: nim r fixdocs.nim htmldocs/* import sugar import os, strutils, sequtils, tables, algorithm, strformat var types_menu: Table[string, string] var types_html: Table[string, string] proc strip_privates(s: string): string = var lines: seq[string] var private = false for line in s.split '\n': if ("*" in line and ":" in line) or "" in line: private = false if "## private" in line: private = true if not private: lines.add line return lines.join "\n" for f in os.commandLineParams(): if f.rsplit("/", 1)[^1] == "types.html": let html = readFile(f) for item in html.split("