From b8956090d952c92ea1668739681c09ed6dbbb0a5 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 14 Jun 2017 14:49:51 +0200 Subject: [PATCH] Fix cyclic build dependency for 06-appearance.md.lua Previously this code checked the generated documentation to decide if something is a class or a module. Now, it parses the source file and looks for the @classmod, @module and @submodule tags to make the same decision. Fixes: https://github.com/awesomeWM/awesome/issues/1255 Signed-off-by: Uli Schlachter --- docs/06-appearance.md.lua | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/docs/06-appearance.md.lua b/docs/06-appearance.md.lua index 0dfad6158..21e08de11 100644 --- a/docs/06-appearance.md.lua +++ b/docs/06-appearance.md.lua @@ -62,31 +62,30 @@ local function path_to_module(path) error("Cannot figure out module for " .. tostring(path)) end -local function module_to_html(mod) - mod = mod:gsub(".init", "") - - local f = io.open("doc/classes/".. mod ..".html","r") - - if f~=nil then - f:close() - return "../classes/".. mod ..".html" +local function path_to_html(path) + local mod = path_to_module(path):gsub(".init", "") + local f = assert(io.open(path)) + while true do + local line = f:read() + if not line then break end + if line:match("@classmod") then + f:close() + return "../classes/".. mod ..".html" + end + if line:match("@module") or line:match("@submodule") then + f:close() + return "../libraries/".. mod ..".html" + end end + f:close() - f = io.open("doc/libraries/".. mod ..".html","r") - - if f~=nil then - f:close() - return "../libraries/".. mod ..".html" - end - - -- This can happen - return "" + error("Cannot figure out if module or class: " .. tostring(path)) end local function get_link(file, element) return table.concat { "",