doc: Prevent ldoc from generating URLs with spaces.

For dubious reasons, ldoc uses the human readable name for the URLs
instead of the machine readable one. If the name has multiple words,
this causes the URLs to have spaces or %20 in them.

This commits remove all spaces from the "kinds" and then use `:gsub()`
in the template to convert underscores to spaces.

**WARNING** This breaks all URLs again. But this is necessary to prevent
broken links when the user paste them with spaces instead of %20.
This commit is contained in:
Emmanuel Lepage Vallee 2019-07-09 16:28:42 -04:00
parent 0e07a34ad6
commit 7cba838067
2 changed files with 8 additions and 7 deletions

View File

@ -100,12 +100,12 @@ sort_modules=true
-- Add more project level (left side index) types.
new_type("widgetmod" , "Widgets" , true)
new_type("containermod", "Widget containers", true)
new_type("layoutmod" , "Widget layouts" , true)
new_type("coreclassmod", "Core components" , true)
new_type("popupmod" , "Popups and bars" , true)
new_type("utillib" , "Utility libraries", true)
new_type("themelib" , "Theme related libraries", true)
new_type("containermod", "Widget_containers", true)
new_type("layoutmod" , "Widget_layouts" , true)
new_type("coreclassmod", "Core_components" , true)
new_type("popupmod" , "Popups_and_bars" , true)
new_type("utillib" , "Utility_libraries", true)
new_type("themelib" , "Theme_related_libraries", true)
file = {
-- C parts of libraries

View File

@ -30,6 +30,7 @@
# local function M(txt,item) return ldoc.markup(txt,item,ldoc.plain) end
# local nowrap = ldoc.wrap and '' or 'nowrap'
# local html_space = function(s) return s:gsub(" ", "%%20") end
# local no_underscores = function(s) return s:gsub("_", " ") end
<!-- Menu -->
@ -68,7 +69,7 @@
# local this_mod = module and module.name
# for kind, mods, type in ldoc.kinds() do
# if ldoc.allowed_in_contents(type,module) then
<h2>$(kind)</h2>
<h2>$(no_underscores(kind))</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap')">
# for mod in mods() do local name = display_name(mod)
# if mod.name == this_mod then