From 4dd689f1816466364f02457eaa14f496f9b9d7f6 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sun, 14 Mar 2021 15:40:48 +0100 Subject: [PATCH 01/17] doc(@supermodule;ldoc.ltp): Draw hierarchy tree This commit adds a new ldoc custom tag `@supermodule`. It has to be used at the module level. It should refer to the module supermodules. This tag can be used multiple time by the same module, but we ignore other calls (for now?) as (AFAIK) we only use one way inheritance. This tag is used in the ldoc template to find modules hierarchy and draw the inheritance tree. It makes it easy to find and navigate to parents modules. --- docs/config.ld | 10 ++++++++++ docs/ldoc.css | 15 ++++++++++++++ docs/ldoc.ltp | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/docs/config.ld b/docs/config.ld index 63b0ad8e..7894127d 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -456,6 +456,16 @@ add_custom_tag { }, } +-- Define the supermodule class. +-- This tag should be used at the module level. All properties from the +-- supermodule will be recursively added to the module by our ldoc template. +-- @supermodule supermodule +add_custom_tag { + name = "supermodule", + hiden = true, + auto_subtags = false +} + -- More fitting section names kind_names={topic='Documentation', module='Libraries', script='Sample files'} diff --git a/docs/ldoc.css b/docs/ldoc.css index 1cb5b83b..b2a22f3b 100644 --- a/docs/ldoc.css +++ b/docs/ldoc.css @@ -503,3 +503,18 @@ pre .url { color: #272fc2; text-decoration: underline; } .index_guides div a:hover { background-color: #99b3ec; } + +/* Inheritance diagram */ +.inheritance .inheritance__level { + list-style: none; +} + +.inheritance .inheritance__level__node::before { + content: "↳"; +} + +.inheritance .inheritance__level__node--root::before { + /* simulate the spacing of the arrow character */ + content: " "; + white-space: pre; +} diff --git a/docs/ldoc.ltp b/docs/ldoc.ltp index 3c878cc3..dda250f2 100644 --- a/docs/ldoc.ltp +++ b/docs/ldoc.ltp @@ -43,6 +43,29 @@ # local html_space = function(s) return s:gsub(" ", "%%20") end # local no_underscores = function(s) return s:gsub("_", " ") end +# --------- modules hierarchy ------------- +# local hierarchy = {} +# local curr = module +# while curr do +# hierarchy[#hierarchy + 1] = curr +# -- no need to do anything more if there is no explicite @supermodule +# if not curr.tags.supermodule then break end +# local super = curr.tags.supermodule[1] -- only consider one way inheritance +# local found = false +# for kind, mods, type in ldoc.kinds() do +# for mod in mods() do +# local name = display_name(mod) +# if name == super then +# curr = mod +# found = true +# end +# if found then break end +# end +# if found then break end +# end +# if not found then curr = nil end +# end +