2019-06-06 08:06:28 +02:00
|
|
|
local args = ...
|
2021-12-21 06:54:15 +01:00
|
|
|
local ldoc = nil
|
2019-06-06 08:06:28 +02:00
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
-- luacheck: globals new_type
|
2019-06-06 08:06:28 +02:00
|
|
|
|
2012-11-19 14:57:47 +01:00
|
|
|
-- Configuration file for ldoc
|
2014-05-25 14:35:44 +02:00
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
project='awesome' -- luacheck: globals project
|
|
|
|
title='awesome API documentation' -- luacheck: globals title
|
|
|
|
description='API documentation for awesome, a highly configurable X window manager (version @AWESOME_VERSION@).' -- luacheck: globals description
|
2014-05-19 11:48:23 +02:00
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
format='discount' -- luacheck: globals format
|
|
|
|
dir='../doc' -- luacheck: globals dir
|
2014-05-19 11:48:23 +02:00
|
|
|
|
|
|
|
-- Make the docs prettier
|
2021-12-21 06:54:15 +01:00
|
|
|
pretty='lua' -- luacheck: globals pretty
|
|
|
|
style=true -- luacheck: globals style
|
|
|
|
template=true -- luacheck: globals template
|
|
|
|
backtick_references=true -- luacheck: globals backtick_references
|
|
|
|
merge=true -- luacheck: globals merge
|
|
|
|
use_markdown_titles=true -- luacheck: globals use_markdown_titles
|
|
|
|
wrap=true -- luacheck: globals wrap
|
|
|
|
|
|
|
|
-- luacheck: globals full_description
|
2016-12-27 14:17:39 +01:00
|
|
|
full_description = [[
|
2020-08-23 10:46:05 +02:00
|
|
|
Welcome to the documentation for the Awesome window manager. Below you find an
|
2016-12-27 14:17:39 +01:00
|
|
|
overview of the individual parts which links to the full documentation.
|
|
|
|
|
|
|
|
If you are a new user, you may want to read @{07-my-first-awesome.md} to get
|
|
|
|
started. In @{05-awesomerc.md}, the default configuration is explained.
|
|
|
|
|
|
|
|
If you already used awesome in the past, @{89-NEWS.md} and @{17-porting-tips.md}
|
|
|
|
should be useful for you.
|
2020-08-23 10:46:05 +02:00
|
|
|
|
|
|
|
### Default configuration components name:
|
|
|
|
|
2022-01-03 02:52:23 +01:00
|
|
|
<center>
|
|
|
|
<object class="img-object" data="images/AUTOGEN_awful_popup_defaultconfig.svg" alt="" type="image/svg+xml"></object>
|
|
|
|
</center>
|
2020-08-23 10:46:05 +02:00
|
|
|
|
|
|
|
### Guides
|
|
|
|
|
|
|
|
<div class="index_guides">
|
|
|
|
<div>
|
2021-08-04 20:07:57 +02:00
|
|
|
@{07-my-first-awesome.md|Getting started}
|
|
|
|
@{90-FAQ.md|FAQ}
|
|
|
|
@{01-readme.md|Read Me}
|
|
|
|
@{89-NEWS.md|NEWS}
|
2020-08-23 10:46:05 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
2021-08-04 20:07:57 +02:00
|
|
|
@{03-declarative-layout.md|The widget system}
|
|
|
|
@{09-options.md|Startup options}
|
|
|
|
@{05-awesomerc.md|The default rc.lua}
|
|
|
|
@{08-client-layout-system.md|Window management}
|
2020-08-23 10:46:05 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
## Major libraries
|
|
|
|
|
|
|
|
AwesomeWM ship multiple libraries. Here is an overview of the purpose and scope
|
|
|
|
of those libraries.
|
|
|
|
|
|
|
|
<table class='widget_list' border=1>
|
|
|
|
<tr style='font-weight: bold;'>
|
|
|
|
<th align='center'>Library</th>
|
|
|
|
<th align='center'>Description</th>
|
|
|
|
</tr>
|
|
|
|
<tr><td>`gears`</td><td>Utilities such as color parsing and objects</td></tr>
|
|
|
|
<tr><td>`wibox`</td><td>Awesome own generic widget framework</td></tr>
|
|
|
|
<tr><td>`awful`</td><td>Everything related to window managment</td></tr>
|
|
|
|
<tr><td>`awful.widget`</td><td>Window management related widgets</td></tr>
|
|
|
|
<tr><td>`awful.layout`</td><td>The default stateless client tiling module.</td></tr>
|
|
|
|
<tr><td>`ruled`</td><td>Define declarative rules on various events</td></tr>
|
|
|
|
<tr><td>`naughty`</td><td>Notifications</td></tr>
|
|
|
|
<tr><td>`menubar`</td><td>XDG (application) menu implementation</td></tr>
|
|
|
|
<tr><td>`beautiful`</td><td>Awesome theme module</td></tr>
|
|
|
|
</table>
|
|
|
|
|
2016-12-27 14:17:39 +01:00
|
|
|
]]
|
2014-05-24 23:25:12 +02:00
|
|
|
topics={
|
2014-05-26 21:26:52 +02:00
|
|
|
'00-authors.md',
|
|
|
|
'01-readme.md',
|
|
|
|
'02-contributing.md',
|
2016-02-10 07:07:47 +01:00
|
|
|
'03-declarative-layout.md',
|
2016-02-10 07:21:29 +01:00
|
|
|
'04-new-widgets.md',
|
2016-08-12 21:18:27 +02:00
|
|
|
'05-awesomerc.md',
|
2016-08-12 08:01:45 +02:00
|
|
|
'06-appearance.md',
|
2016-12-27 13:57:56 +01:00
|
|
|
'07-my-first-awesome.md',
|
2019-12-12 19:06:07 +01:00
|
|
|
'08-client-layout-system.md',
|
2020-02-03 02:56:27 +01:00
|
|
|
'09-options.md',
|
2021-03-10 22:47:13 +01:00
|
|
|
'10-building-and-testing.md',
|
2016-06-11 05:53:17 +02:00
|
|
|
'16-using-cairo.md',
|
2016-12-21 03:59:07 +01:00
|
|
|
'17-porting-tips.md',
|
2016-04-30 11:54:16 +02:00
|
|
|
'90-FAQ.md',
|
2016-12-10 05:55:48 +01:00
|
|
|
'89-NEWS.md',
|
2014-05-24 23:25:12 +02:00
|
|
|
}
|
2015-02-15 22:33:23 +01:00
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
local databases, named_tags, item_id, is_init = {}, {}, 1, false
|
|
|
|
local all_theme_vars, delayed_collect = nil, {}
|
|
|
|
|
|
|
|
local function collect_item_common(tab, mod, item)
|
|
|
|
tab[item.name] = tab[item.name] or {}
|
|
|
|
|
|
|
|
local var = tab[item.name]
|
|
|
|
var[mod.name] = var[mod.name] or {}
|
|
|
|
var[mod.name][#var[mod.name] + 1] = item
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Add another custom tag **value** to an existing item.
|
|
|
|
-- @tparam string tag_data The raw/unparsed string for the
|
|
|
|
-- tag. It will be parsed like any other tags.
|
|
|
|
local function add_custom_tag_common(item, tag_name, meta_tag, tag_data)
|
|
|
|
item.tags = item.tags or {}
|
|
|
|
|
|
|
|
item.tags[tag_name] = item.tags[tag_name] or {}
|
|
|
|
|
|
|
|
item.tags[tag_name][#item.tags[tag_name] + 1] = tag_data
|
|
|
|
|
|
|
|
if meta_tag.collect_callback then
|
|
|
|
delayed_collect[#delayed_collect+1] = {item, item.module, tag_name, tag_data}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Wrap the global `new_type` to allow us to extend what types can do, the
|
|
|
|
-- same is done below for custom tags.
|
|
|
|
local function create_type(args)
|
|
|
|
new_type(args.name, args.title, args.project_level, args.subfield_title)
|
|
|
|
|
|
|
|
databases[args.name] = databases[args.name] or {}
|
|
|
|
databases[args.name].collect = args.collect_callback
|
|
|
|
databases[args.name].finish = args.finish_callback
|
|
|
|
|
|
|
|
return args
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Add the @usebeautiful from the optional/default value.
|
|
|
|
local function auto_add_usebeautiful(item)
|
|
|
|
local vars, var_names = {}, {}
|
|
|
|
|
|
|
|
-- Datamine the default values to autogenerate the @usebeautiful.
|
|
|
|
for parm in ldoc.modules.iter(item.params) do
|
|
|
|
for p in ldoc.modules.iter(item:subparam(parm)) do
|
|
|
|
local def = item:default_of_param(p)
|
|
|
|
|
|
|
|
if def and def ~= true then
|
|
|
|
for var in def:gmatch("beautiful[.][a-z_]+") do
|
|
|
|
if not var_names[var] then
|
|
|
|
vars[#vars+1] = var
|
|
|
|
end
|
|
|
|
var_names[var] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, var in ipairs(vars) do
|
|
|
|
named_tags.usebeautiful:add_to_item(item, var)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-07 20:59:34 +02:00
|
|
|
-- The first stereotype are the constructors.
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "constructorfct",
|
|
|
|
title = "Constructors",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
collect_callback = auto_add_usebeautiful,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Some constructors like `awful.key` have both a named parameter
|
|
|
|
-- syntax and a multiple function parameter syntax.
|
|
|
|
create_type {
|
|
|
|
name = "constructorfct2",
|
|
|
|
title = "ldoc_skip",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2019-06-06 22:32:53 +02:00
|
|
|
-- Hack to get the functions on top of the signals and properties
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "function",
|
|
|
|
title = "Functions",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2019-06-08 01:08:05 +02:00
|
|
|
-- For "classes", use an explicit type for static functions. This allows
|
|
|
|
-- @function and its implicit cousin to be banned in the CI.
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "staticfct",
|
|
|
|
title = "Static module functions",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2016-04-03 08:59:50 +02:00
|
|
|
-- Documentation for objects properties
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "property",
|
|
|
|
title = "Object properties",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Type constraints",
|
|
|
|
collect_callback = auto_add_usebeautiful,
|
|
|
|
finish_callback = function(item)
|
|
|
|
-- All properties need to have a type. Otherwise they don't render
|
|
|
|
-- properly. Also, because typed properties are kind of the point of
|
|
|
|
-- switching to ldoc in the first place.
|
|
|
|
if (not item.params) or not item.params[1] then
|
|
|
|
print(
|
|
|
|
"WARNING: The ".. item.name .." property from "..item.module.name.." is missing it's type."
|
|
|
|
)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local param = item:subparam(item.params[1])
|
|
|
|
local type = item:type_of_param(param[1])
|
|
|
|
|
|
|
|
-- Force people to use @tparam because it is easier to lint and allows
|
|
|
|
-- multiple types.
|
|
|
|
if (not type) or type == "" then
|
|
|
|
print(
|
|
|
|
"WARNING: Property ".. item.name .." from "..item.module.name.." either "..
|
|
|
|
" doesn't have a type or uses @param instead of @tparam. @tparam is required"..
|
|
|
|
" because it allows multi-type and better default value handling."
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- One of the repeated problem we have is the first word of the
|
|
|
|
-- description being removed because it is used as the property name.
|
|
|
|
-- This "rule" might be stupid, but it prevents it from accidentally
|
|
|
|
-- happening again.
|
|
|
|
if item.params[1] ~= item.name:match("[.]?("..item.params[1]..")$") then
|
|
|
|
print(
|
|
|
|
"WARNING: Property ".. item.name .." from "..item.module.name.." @tparam name"..
|
|
|
|
" doesn't match the property name. For linting purpose, please fix this."
|
|
|
|
)
|
|
|
|
end
|
2022-07-10 09:29:33 +02:00
|
|
|
|
|
|
|
-- Properties should have a default value. If they don't or if the
|
|
|
|
-- default depends on the context, then `opt=nil` should be used to
|
|
|
|
-- mute this warning.
|
|
|
|
if not item:default_of_param(item.params[1]) then
|
|
|
|
local auto_opt = nil
|
|
|
|
|
|
|
|
-- Extract the default value from other metadata.
|
|
|
|
if item.tags["propbeautiful"] and item.tags["propbeautiful"][1] then
|
|
|
|
auto_opt = "beautiful."..(item.module.name.."_"..item.name):gsub("[.]", "_")
|
|
|
|
elseif item.tags["usebeautiful"] and item.tags["usebeautiful"][1] then
|
|
|
|
auto_opt = item.tags["usebeautiful"][1]:match("[^ ]+")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- This adds a default value. It works for LDoc 1.4.5, but is a
|
|
|
|
-- private API and might break in the future.
|
|
|
|
if auto_opt then
|
|
|
|
local mods = item.modifiers[item.parameter]
|
|
|
|
|
|
|
|
if mods then
|
|
|
|
mods[item.params[1]].opt = auto_opt
|
|
|
|
end
|
|
|
|
else
|
|
|
|
-- The default could not be determined automatically, it requires
|
|
|
|
-- an explicit `opt=<value>`.
|
|
|
|
print(
|
|
|
|
"WARNING: Property", item.name .." from "..item.module.name --,
|
|
|
|
--"doesn't have a default value. Add `[opt=value]` to the @tparam"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2021-12-21 06:54:15 +01:00
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2019-03-12 19:36:32 +01:00
|
|
|
-- Documentation for objects deprecated properties
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "deprecatedproperty",
|
|
|
|
title = "Deprecated object properties",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Type constraints",
|
|
|
|
}
|
|
|
|
|
2021-12-08 21:24:46 +01:00
|
|
|
-- Documentation for objects deprecated methods
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "deprecatedmethod",
|
|
|
|
title = "Deprecated object methods",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2019-06-06 22:32:53 +02:00
|
|
|
-- Use a custom type for the methods to bypass the faulty ldoc built-in detection.
|
|
|
|
-- (yes, the space after Methods *is* on purpose to avoid clashing with ldoc
|
|
|
|
-- internal "methods" concept)
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "method",
|
|
|
|
title = "Object methods ",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
|
|
|
-- New type for signals.
|
|
|
|
local all_signals
|
|
|
|
all_signals = create_type {
|
|
|
|
name = "signal",
|
|
|
|
title = "Signals",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Arguments",
|
|
|
|
collection = {},
|
|
|
|
collect_callback = function(item, mod)
|
|
|
|
collect_item_common(all_signals.collection, mod, item)
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
2019-11-10 07:12:43 +01:00
|
|
|
-- Deprecated signals.
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "deprecatedsignal",
|
|
|
|
title = "Deprecated signals",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Arguments",
|
|
|
|
}
|
|
|
|
|
2016-04-25 04:42:32 +02:00
|
|
|
-- New type for signals connections
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "signalhandler",
|
|
|
|
title = "Request handlers",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Arguments",
|
|
|
|
}
|
|
|
|
|
2016-04-03 08:59:50 +02:00
|
|
|
-- Allow objects to define a set of beautiful properties affecting them
|
2021-12-21 06:54:15 +01:00
|
|
|
all_theme_vars = create_type {
|
|
|
|
name = "beautiful",
|
|
|
|
title = "Theme variables",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Type constraints",
|
|
|
|
collection = {},
|
|
|
|
collect_callback = function(item, mod)
|
|
|
|
if item.name:sub(1,4) ~= "beau" then
|
|
|
|
-- This would be a bug.
|
|
|
|
if item.name:match("[.]") then
|
|
|
|
print("WANRING: A beautiful variable is called `", item.name, "`. This name is invalid.")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- This happens because the `ldoc` messes with the name. All variables
|
|
|
|
if item.module.name == "beautiful" then
|
|
|
|
item.name = "beautiful." .. item.name
|
|
|
|
else
|
|
|
|
print(
|
|
|
|
"WARNING: All theme variable need a `beautiful.` prefix. It appears",
|
|
|
|
item.name,
|
|
|
|
" lacks it"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
collect_item_common(all_theme_vars.collection, mod, item)
|
|
|
|
|
|
|
|
-- Those are global variables, there can be only one per name.
|
|
|
|
if all_theme_vars.collection[item.name] then
|
|
|
|
local mod = pairs(all_theme_vars.collection[item.name])(all_theme_vars.collection[item.name])
|
|
|
|
|
|
|
|
if mod ~= item.module.name then
|
|
|
|
print("ERROR: "..item.name, "from", item.module.name, "is already defined in module ", mod)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
finish_callback = function(item)
|
|
|
|
if item.tags["beautiful_used_by"] then return end
|
|
|
|
|
|
|
|
-- Every variable should be consumed by something. Better "park" some
|
|
|
|
-- variable in the constructors than leave them disconnected from the
|
|
|
|
-- global model.
|
|
|
|
print("WARNING: ", item.name, "is not used by anything, add @usebeautiful or @propbeautiful")
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2016-04-03 08:59:50 +02:00
|
|
|
-- Put deprecated methods in their own section
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "deprecated",
|
|
|
|
title = "Deprecated functions",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2016-04-03 08:59:50 +02:00
|
|
|
-- For the legacy stateless layout related functions
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "legacylayout",
|
|
|
|
title = "Layout related functions",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2016-12-10 02:24:22 +01:00
|
|
|
-- Have a category for the client layouts
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "clientlayout",
|
|
|
|
title = "Client layouts",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2018-08-18 22:26:59 +02:00
|
|
|
-- Source functions for the taglist/tasklist/layoutlist
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "sourcefunction",
|
|
|
|
title = "List source functions",
|
|
|
|
project_level = false,
|
|
|
|
}
|
|
|
|
|
2016-12-30 07:49:04 +01:00
|
|
|
-- Document some callback prototypes
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "callback",
|
|
|
|
title = "Callback functions prototype",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2019-02-24 21:24:58 +01:00
|
|
|
-- gears.matcher / awful.rules sources
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "rulesources",
|
|
|
|
title = "Rule sources",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Parameters",
|
|
|
|
}
|
|
|
|
|
2019-02-24 21:24:58 +01:00
|
|
|
-- gears.matcher / awful.rules rule components
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "rulecomponent",
|
|
|
|
title = "Rule components",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Type",
|
|
|
|
}
|
|
|
|
|
2018-08-18 21:47:14 +02:00
|
|
|
-- Filter functions for the taglist/tasklist/layoutlist
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "filterfunction",
|
|
|
|
title = "List filters",
|
|
|
|
project_level = false,
|
|
|
|
}
|
|
|
|
|
2018-10-07 01:40:36 +02:00
|
|
|
-- Extra client properties available only in awful.rules/spawn constructs
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "clientruleproperty",
|
|
|
|
title = "Extra properties available in the rules",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Type",
|
|
|
|
}
|
|
|
|
|
2019-08-18 10:39:01 +02:00
|
|
|
-- Extra *matching* properties for rules.
|
2021-12-21 06:54:15 +01:00
|
|
|
create_type {
|
|
|
|
name = "matchingproperty",
|
|
|
|
title = "Extra matching properties used in rules",
|
|
|
|
project_level = false,
|
|
|
|
subfield_title = "Type",
|
|
|
|
}
|
2014-05-19 11:48:23 +02:00
|
|
|
|
2019-11-24 09:56:19 +01:00
|
|
|
-- Simulate the default "params" parser format, except the optional "[]" section
|
|
|
|
-- needs a space.
|
|
|
|
local function parse_custom_tags(text, params)
|
|
|
|
text = text:gmatch("[ ]*(.*)$")()
|
|
|
|
local raw_extra = ""
|
|
|
|
|
|
|
|
if text:sub(1,1) == '[' then
|
|
|
|
local count = 1
|
|
|
|
|
|
|
|
-- Find the matching ']'
|
|
|
|
for i=2, text:len() do
|
|
|
|
local char = text:sub(i,i)
|
|
|
|
|
|
|
|
if char == '[' then
|
|
|
|
count = count + 1
|
|
|
|
elseif char == ']' then
|
|
|
|
count = count - 1
|
|
|
|
end
|
|
|
|
|
|
|
|
raw_extra = raw_extra..char
|
|
|
|
|
|
|
|
if count == 0 then
|
|
|
|
text = text:sub(i+2)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Split the remaining text into words.
|
|
|
|
local words, values, description = {}, {}, {}
|
|
|
|
|
|
|
|
for word in text:gmatch("[^ \n\r]*") do
|
|
|
|
if word ~= "" then
|
|
|
|
words[#words+1] = word
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for idx, word in ipairs(words) do
|
|
|
|
if idx <= #params then
|
|
|
|
local name = params[idx].name
|
|
|
|
values[name] = {
|
|
|
|
name = name,
|
|
|
|
title = params[idx].title or name,
|
|
|
|
value = word
|
|
|
|
}
|
|
|
|
else
|
|
|
|
description[#description+1] = word
|
|
|
|
values.description = values.description and
|
|
|
|
values.description.." "..word or
|
|
|
|
word
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return values
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Mimic the template classes.
|
|
|
|
local function default_format_callback(self, params, _, md)
|
|
|
|
local ret = ""
|
|
|
|
|
|
|
|
if self.table then
|
|
|
|
-- All columns are mandatory
|
|
|
|
for _, p in ipairs(self.params) do
|
|
|
|
local content = params[p.name] and params[p.name].value or ""
|
|
|
|
ret = ret.."<td>"..(p.markdown and md("`"..content.."`") or content).."</td>"
|
|
|
|
end
|
|
|
|
return ret .. "<td>"..md(params.description).."</td>"
|
|
|
|
else
|
|
|
|
if params.name then
|
|
|
|
ret = '<span class="parameter">'..
|
|
|
|
md("`"..params.name.value.."`")..
|
|
|
|
"</span> "
|
|
|
|
end
|
|
|
|
|
|
|
|
if params.type then
|
2019-12-05 19:05:36 +01:00
|
|
|
ret = ret .. '<span class="types">'..
|
2019-11-24 09:57:46 +01:00
|
|
|
md("`"..params.type.value.."`")..
|
2019-12-05 19:05:36 +01:00
|
|
|
"</span>"
|
2019-11-24 09:56:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return ret.." "..md(params.description)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Generate a format function.
|
2021-12-21 06:54:15 +01:00
|
|
|
local function default_format(self, callback, name)
|
2019-11-24 09:56:19 +01:00
|
|
|
return function(raw, item, md)
|
2021-12-21 06:54:15 +01:00
|
|
|
local p = name and item.parsed_tags and item.parsed_tags[name] and item.parsed_tags[name][raw]
|
|
|
|
|
|
|
|
if not p then
|
|
|
|
p = parse_custom_tags(raw, self.params or {})
|
|
|
|
end
|
|
|
|
|
|
|
|
return (callback or default_format_callback)(self, p, item, md)
|
2019-11-24 09:56:19 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Add a new @something which can be used in any types.
|
|
|
|
-- @tparam table args
|
|
|
|
-- @tparam string args.name The name.
|
|
|
|
-- @tparam string args.hidden Show in the doc or for internal use only.
|
|
|
|
-- @tparam table args.table Show the items in a table rather than a list. The
|
|
|
|
-- content is the list of header names.
|
|
|
|
-- @tparam table args.params The parameters (table with name, tilte, format).
|
|
|
|
-- @tparam boolean[opt=true] args.auto_subtags Create the usage and tparams subtags.
|
|
|
|
local add_custom_tag
|
|
|
|
add_custom_tag = function(args)
|
|
|
|
local name = args.name
|
|
|
|
|
|
|
|
args.name, args[1] = nil, name
|
|
|
|
|
|
|
|
custom_tags = custom_tags or {}
|
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
databases[name] = databases[name] or {}
|
|
|
|
databases[name].collect = args.collect_callback
|
|
|
|
|
2019-11-24 09:56:19 +01:00
|
|
|
local f = args.format
|
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
args.format = default_format(args, f, name)
|
|
|
|
|
|
|
|
function args:add_to_item(item, tag_value)
|
|
|
|
add_custom_tag_common(item, name, args, tag_value)
|
|
|
|
|
|
|
|
local parsed = parse_custom_tags(tag_value, args.params or {})
|
|
|
|
|
|
|
|
if parsed then
|
|
|
|
item.parsed_tags = item.parsed_tags or {}
|
|
|
|
item.parsed_tags[name] = item.parsed_tags[name] or {}
|
|
|
|
item.parsed_tags[name][tag_value] = parsed
|
|
|
|
end
|
|
|
|
|
|
|
|
item.has_show_more = item.has_show_more or (not args.hidden)
|
|
|
|
end
|
2019-11-24 09:56:19 +01:00
|
|
|
|
|
|
|
custom_tags[#custom_tags+1] = args
|
|
|
|
named_tags[name] = args
|
|
|
|
|
|
|
|
-- Auto create @name_tparams and @name_usage for each custom tags.
|
|
|
|
if args.auto_subtags ~= false then
|
|
|
|
add_custom_tag {
|
|
|
|
name = name.."tparam",
|
|
|
|
auto_params = true,
|
|
|
|
parent = args,
|
|
|
|
auto_subtags = false,
|
|
|
|
params = {
|
|
|
|
{ name = "type" },
|
|
|
|
{ name = "name" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add_custom_tag {
|
|
|
|
name = name.."usage",
|
|
|
|
auto_usage = true,
|
|
|
|
parent = args,
|
|
|
|
auto_subtags = false,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-24 09:57:46 +01:00
|
|
|
-- When a type will request a permission.
|
|
|
|
-- @emits class signal Message[...]
|
|
|
|
add_custom_tag {
|
|
|
|
name = "emits",
|
|
|
|
title = "Emit signals",
|
|
|
|
hidden = false,
|
|
|
|
params = {
|
|
|
|
{
|
|
|
|
name = "name"
|
|
|
|
}
|
2021-12-21 06:54:15 +01:00
|
|
|
},
|
|
|
|
collect_callback = function(item, mod, tag, value)
|
|
|
|
local parsed = parse_custom_tags(value, named_tags.emits.params)
|
|
|
|
|
|
|
|
all_signals.collection[parsed.name.value] = all_signals.collection[parsed.name.value] or {}
|
|
|
|
|
|
|
|
local var = all_signals.collection[parsed.name.value]
|
|
|
|
|
|
|
|
var[mod.name] = var[mod.name] or {}
|
|
|
|
var[mod.name][#var[mod.name] + 1] = item
|
|
|
|
end
|
2019-11-24 09:57:46 +01:00
|
|
|
}
|
|
|
|
|
2019-11-25 00:48:13 +01:00
|
|
|
-- Avoid repetitive boilerplate code for property signals.
|
|
|
|
-- Add true if the signal has the value or false if it doesn't.
|
|
|
|
-- @propemits true/false true/false description[...]
|
|
|
|
add_custom_tag {
|
|
|
|
name = "propemits",
|
2019-12-05 18:39:51 +01:00
|
|
|
title = "Emit signals",
|
2019-11-25 00:48:13 +01:00
|
|
|
hidden = false,
|
|
|
|
params = {{name = "new_value"}, {name = "old_value"}},
|
|
|
|
format = function(self, params, item, md)
|
|
|
|
-- Add an automatic fallback description.
|
|
|
|
local description = params.description ~= "" and params.description or
|
|
|
|
"When the `"..item.name.."` value changes."
|
|
|
|
local new_value = params.new_value.value == "true"
|
|
|
|
local old_value = params.old_value.value == "true"
|
|
|
|
|
|
|
|
-- Add the sub-tags.
|
|
|
|
local subs = {}
|
|
|
|
item.auto_params["propemitstparam_override"] = subs
|
|
|
|
|
|
|
|
-- The first argument is always the object which changes.
|
|
|
|
subs[1] = item.module.name.." self ".." The object which changed ("..
|
|
|
|
"useful when connecting many object to the same callback)."
|
|
|
|
|
|
|
|
-- Most signals also have the new value.
|
|
|
|
if new_value then
|
|
|
|
local type = item.params[1] or "unknown"
|
2019-12-05 18:39:51 +01:00
|
|
|
subs[2] = type.." ".."new_value The new value affected to the property."
|
2019-11-25 00:48:13 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Some also have the old value.
|
|
|
|
if old_value then
|
|
|
|
local type = item.params[1] or "unknown"
|
2019-12-05 18:39:51 +01:00
|
|
|
subs[3] = type.." ".."old_value The property's old value."
|
2019-11-25 00:48:13 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local new_params = {
|
2019-12-05 18:39:51 +01:00
|
|
|
name = { name = item.name, value = "property::"..item.name },
|
|
|
|
description = description
|
2019-11-25 00:48:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return default_format_callback(self, new_params, item, md)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2019-11-27 19:11:20 +01:00
|
|
|
-- List the beautiful variables used by the method or property fallbacks.
|
2019-11-24 09:58:32 +01:00
|
|
|
-- @usebeautiful beautiful.varname usage[...]
|
|
|
|
add_custom_tag {
|
|
|
|
name = "usebeautiful",
|
|
|
|
title = "Consumed theme variables",
|
|
|
|
hidden = false,
|
|
|
|
table = {
|
|
|
|
"Variable", "Usage"
|
|
|
|
},
|
|
|
|
params = {
|
|
|
|
{
|
|
|
|
name = "name",
|
|
|
|
markdown = true,
|
|
|
|
}
|
2021-12-21 06:54:15 +01:00
|
|
|
},
|
|
|
|
collect_callback = function(item, mod, tag, value)
|
|
|
|
local params = parse_custom_tags(value, named_tags.usebeautiful.params)
|
|
|
|
|
|
|
|
if all_theme_vars.collection[params.name.value] then
|
|
|
|
local sig_mods = all_theme_vars.collection[params.name.value]
|
|
|
|
local _, themed_items = pairs(sig_mods)(sig_mods)
|
|
|
|
local themed_item = themed_items[1]
|
|
|
|
|
|
|
|
named_tags.beautiful_used_by:add_to_item(themed_item, item.name.." "..item.summary)
|
|
|
|
|
|
|
|
-- Auto fill the description if its empty.
|
|
|
|
if (not params.description) or params.description == "" then
|
|
|
|
params.description = themed_item.summary
|
|
|
|
end
|
|
|
|
else
|
|
|
|
print("WARNING: Could not find theme variable", params.name.value)
|
|
|
|
end
|
|
|
|
end
|
2019-11-24 09:58:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-25 05:04:13 +01:00
|
|
|
-- For all properties which have a standard `@beautiful` variable for them
|
|
|
|
-- @propbeautiful fallback1 fallback2 fallback3 fallback4
|
|
|
|
add_custom_tag {
|
|
|
|
name = "propbeautiful",
|
|
|
|
title = "Consumed theme variables",
|
|
|
|
params = {
|
|
|
|
{ name = "fallback1" },
|
|
|
|
{ name = "fallback2" },
|
|
|
|
{ name = "fallback3" },
|
|
|
|
{ name = "fallback4" },
|
|
|
|
},
|
|
|
|
table = {
|
|
|
|
"Variable", "Usage"
|
|
|
|
},
|
|
|
|
format = function(self, p, item, md)
|
|
|
|
local modname = item.module.name:gmatch("[^.]+$")()
|
|
|
|
local last = "beautiful."..(modname.."_"..item.name):gsub("[.]", "_")
|
|
|
|
local ret = "<td>"..md("`"..last.."`").."</td><td>Fallback when "..md("`"..item.name.."`")..
|
|
|
|
" isn't set.</td>"
|
|
|
|
|
|
|
|
for _, fallback in ipairs({p.fallback1, p.fallback2, p.fallback3, p.fallback4 }) do
|
|
|
|
ret = ret .. "</tr><tr>"..
|
|
|
|
"<td>"..md("`"..fallback.value.."`").."</td><td>Fallback when "..md("`"..last.."`")..
|
|
|
|
" isn't set.</td>"
|
|
|
|
last = fallback.value
|
|
|
|
end
|
|
|
|
|
|
|
|
return ret
|
2021-12-21 06:54:15 +01:00
|
|
|
end,
|
|
|
|
finish_callback = function(item, raw, params, modules)
|
|
|
|
local modname = item.module.name:gmatch("[^.]+$")()
|
|
|
|
local name = "beautiful."..(modname.."_"..item.name):gsub("[.]", "_")
|
|
|
|
|
|
|
|
if all_theme_vars.collection[name] then
|
|
|
|
local sig_mods = all_theme_vars.collection[name]
|
|
|
|
local _, themed_items = pairs(sig_mods)(sig_mods)
|
|
|
|
local themed_item = themed_items[1]
|
|
|
|
|
|
|
|
named_tags.beautiful_used_by:add_to_item(themed_item, item.name.." "..item.summary)
|
|
|
|
end
|
2019-11-25 05:04:13 +01:00
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2019-11-24 09:58:54 +01:00
|
|
|
-- Define the base class where a method/property is implemented.
|
|
|
|
-- @baseclass my_module.my_submodule.my_baseclass
|
|
|
|
add_custom_tag {
|
|
|
|
name = "baseclass",
|
|
|
|
hidden = true
|
|
|
|
}
|
|
|
|
|
2019-11-29 00:52:32 +01:00
|
|
|
-- Define which interface a method or property implements.
|
|
|
|
-- @interface container
|
|
|
|
add_custom_tag {
|
|
|
|
name = "interface",
|
|
|
|
hidden = true
|
|
|
|
}
|
|
|
|
|
2019-12-01 06:36:08 +01:00
|
|
|
-- Define when a signal is only emitted on a class rather than on objects.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "classsignal",
|
|
|
|
hidden = true,
|
|
|
|
}
|
|
|
|
|
2019-11-29 00:37:57 +01:00
|
|
|
-- Specify when this an item was deprecated.
|
|
|
|
-- @deprecatedin 4.4 Optional message.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "deprecatedin",
|
|
|
|
hidden = true,
|
|
|
|
params = {
|
|
|
|
{ name = "api_level" },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Specify when this an item was deprecated because it was renamed.
|
|
|
|
-- @renamedin 4.4 new_name Optional message.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "renamedin",
|
|
|
|
hidden = true,
|
|
|
|
params = {
|
|
|
|
{ name = "api_level" },
|
|
|
|
{ name = "new_name" },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Specify when this an item was deprecated because it was moved.
|
|
|
|
-- @movedin 4.4 new_class new_name Optional message.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "movedin",
|
|
|
|
hidden = true,
|
|
|
|
params = {
|
|
|
|
{ name = "api_level" },
|
|
|
|
{ name = "new_class" },
|
|
|
|
{ name = "new_name" },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-11-29 00:43:16 +01:00
|
|
|
-- Specify when an item was added.
|
|
|
|
-- @introducedin 4.4
|
|
|
|
add_custom_tag {
|
|
|
|
name = "introducedin",
|
|
|
|
hidden = true,
|
|
|
|
params = {
|
|
|
|
{ name = "api_level" },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-12-01 07:48:58 +01:00
|
|
|
add_custom_tag {
|
|
|
|
name = "request",
|
|
|
|
title = "Requested actions or permissions",
|
|
|
|
params = {
|
|
|
|
{ name = "class" },
|
|
|
|
{ name = "type" },
|
|
|
|
{ name = "context" },
|
|
|
|
{ name = "default" },
|
|
|
|
},
|
|
|
|
table = {
|
|
|
|
"Class", "Permission", "Context", "Default", "Description"
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-03-14 15:40:48 +01:00
|
|
|
-- 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",
|
2021-03-28 18:19:08 +02:00
|
|
|
hidden = true,
|
|
|
|
auto_subtags = false
|
|
|
|
}
|
|
|
|
|
2021-10-27 00:06:38 +02:00
|
|
|
-- Mark the item as hidden.
|
2021-03-28 18:19:08 +02:00
|
|
|
-- This tag should be used to hide items from the documentation.
|
|
|
|
-- @hidden
|
|
|
|
add_custom_tag {
|
|
|
|
name = "hidden",
|
|
|
|
hidden = true,
|
2021-03-14 15:40:48 +01:00
|
|
|
}
|
|
|
|
|
2021-10-27 00:07:20 +02:00
|
|
|
-- Mark the item as readonly.
|
|
|
|
-- This tag should be used to mark readonly properties.
|
|
|
|
-- @readonly
|
|
|
|
add_custom_tag {
|
|
|
|
name = "readonly",
|
|
|
|
hidden = true,
|
|
|
|
auto_subtags = false
|
|
|
|
}
|
2021-12-21 06:54:15 +01:00
|
|
|
|
2022-07-05 10:37:14 +02:00
|
|
|
-- Forces every method and function to have either `@treturn` or `@noreturn`.
|
|
|
|
-- This avoids the many case where the return value was forgotten.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "noreturn",
|
|
|
|
hidden = true,
|
|
|
|
auto_subtags = false
|
|
|
|
}
|
|
|
|
|
2022-07-11 07:56:54 +02:00
|
|
|
-- When properties are integers, the value usually has a meaning, like the PID,
|
|
|
|
-- apoint or a pixel.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "propertyunit",
|
|
|
|
hidden = true,
|
|
|
|
auto_subtags = false
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Some string properties are de-facto enums. Only a small set of value is valid.
|
|
|
|
-- This tag provides a consistent rendering for such properties.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "propertyvalue",
|
|
|
|
hidden = true,
|
|
|
|
auto_subtags = false
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Some values, mostly bytes, have a minimum and maximum value.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "rangestart",
|
|
|
|
hidden = true,
|
|
|
|
auto_subtags = false
|
|
|
|
}
|
|
|
|
add_custom_tag {
|
|
|
|
name = "rangestop",
|
|
|
|
hidden = true,
|
|
|
|
auto_subtags = false
|
|
|
|
}
|
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
add_custom_tag {
|
|
|
|
name = "signalhandler",
|
|
|
|
hidden = false,
|
|
|
|
title = "Request handler",
|
|
|
|
auto_subtags = false,
|
|
|
|
params = {
|
|
|
|
{ name = "source" },
|
|
|
|
},
|
|
|
|
format = function(self, params, item, md)
|
|
|
|
return ldoc.markup("`"..params.source.value.."`") .. " " .. params.description
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
add_custom_tag {
|
|
|
|
name = "beautiful_used_by",
|
|
|
|
hidden = false,
|
|
|
|
title = "Used by",
|
|
|
|
auto_subtags = false,
|
|
|
|
params = {
|
|
|
|
{ name = "source" },
|
|
|
|
},
|
|
|
|
format = function(self, params, item, md)
|
|
|
|
return ldoc.markup("`"..params.source.value.."`") .. " " .. params.description
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Auto generate some code for replacing request handlers.
|
|
|
|
add_custom_tag {
|
|
|
|
name = "sourcesignal",
|
|
|
|
title = "Source signal",
|
|
|
|
hidden = false,
|
|
|
|
params = {
|
|
|
|
{ name = "class" },
|
|
|
|
{ name = "signal" },
|
|
|
|
},
|
|
|
|
format = function(self, params, item, md)
|
|
|
|
return ldoc.markup("`"..params.signal.value.."` from the `"..params.class.value.."` module.")..
|
|
|
|
" This code allows to disconnect this handler and implement your own:"
|
|
|
|
end,
|
|
|
|
finish_callback = function(item, raw, params, modules)
|
|
|
|
if all_signals.collection[params.signal.value] then
|
|
|
|
local sig_mods = all_signals.collection[params.signal.value]
|
|
|
|
local _, signal_items = pairs(sig_mods)(sig_mods)
|
|
|
|
local signal_item = signal_items[1]
|
|
|
|
|
|
|
|
-- Auto generate some code.
|
|
|
|
local code = "-- Disconnect the original handler.\n"
|
|
|
|
code = code .. signal_item.module.name .. ".disconnect_signal('".. params.signal.value .."', "..item.name..")\n\n"
|
|
|
|
code = code .. "-- Connect a custom handler.\n"
|
|
|
|
code = code .. signal_item.module.name .. ".connect_signal('".. params.signal.value .."', function("
|
|
|
|
|
|
|
|
|
|
|
|
if signal_item.type == "signal" then
|
|
|
|
for idx, parm in ipairs(signal_item.params) do
|
|
|
|
code = code .. parm .. (idx == #signal_item.params and "" or ", ")
|
|
|
|
end
|
|
|
|
|
|
|
|
code = code .. ")\n -- code here\nend)"
|
|
|
|
|
|
|
|
named_tags.signalhandler:add_to_item(signal_item, item.name.." "..item.summary)
|
|
|
|
end
|
|
|
|
|
|
|
|
item.tag_extra_data = item.tag_extra_data or {}
|
|
|
|
item.tag_extra_data["sourcesignal"] = item.tag_extra_data["sourcesignal"] or {}
|
|
|
|
item.tag_extra_data["sourcesignal"][raw] = item.tag_extra_data["sourcesignal"][raw] or {}
|
|
|
|
item.tag_extra_data["sourcesignal"][raw].usage = ldoc.prettify(code)
|
|
|
|
|
|
|
|
item.has_show_more = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2015-02-20 15:24:26 +01:00
|
|
|
-- More fitting section names
|
2017-02-25 21:41:54 +01:00
|
|
|
kind_names={topic='Documentation', module='Libraries', script='Sample files'}
|
2015-02-20 15:24:26 +01:00
|
|
|
|
|
|
|
-- Sort modules alphabetically
|
|
|
|
sort_modules=true
|
|
|
|
|
2019-06-06 08:06:28 +02:00
|
|
|
-- Add more project level (left side index) types.
|
2019-10-01 07:18:15 +02:00
|
|
|
new_type("coreclassmod", "Core_components" , true)
|
2019-12-31 08:13:25 +01:00
|
|
|
new_type("inputmodule" , "Input_handling" , true)
|
2019-08-18 07:53:07 +02:00
|
|
|
new_type("ruleslib" , "Declarative_rules", true)
|
|
|
|
new_type("widgetmod" , "Widgets" , true)
|
2019-07-09 22:28:42 +02:00
|
|
|
new_type("containermod", "Widget_containers", true)
|
|
|
|
new_type("layoutmod" , "Widget_layouts" , true)
|
|
|
|
new_type("popupmod" , "Popups_and_bars" , true)
|
|
|
|
new_type("utillib" , "Utility_libraries", true)
|
|
|
|
new_type("themelib" , "Theme_related_libraries", true)
|
2019-06-06 08:06:28 +02:00
|
|
|
|
2014-05-19 11:48:23 +02:00
|
|
|
file = {
|
2015-02-27 00:24:23 +01:00
|
|
|
-- C parts of libraries
|
|
|
|
'../dbus.c',
|
|
|
|
'../luaa.c',
|
|
|
|
'../mouse.c',
|
|
|
|
'../mousegrabber.c',
|
|
|
|
'../root.c',
|
|
|
|
'../selection.c',
|
|
|
|
'../spawn.c',
|
|
|
|
'../xkb.c',
|
2017-07-02 17:12:12 +02:00
|
|
|
'../objects/client.c',
|
|
|
|
'../objects/drawable.c',
|
|
|
|
'../objects/screen.c',
|
|
|
|
'../objects/tag.c',
|
|
|
|
'../objects/window.c',
|
|
|
|
|
2014-05-24 23:25:12 +02:00
|
|
|
-- LUA libraries
|
2014-05-26 21:26:52 +02:00
|
|
|
'../lib/',
|
2017-02-25 21:41:54 +01:00
|
|
|
-- Auto generated scripts
|
|
|
|
'../script_files/',
|
2014-05-19 11:48:23 +02:00
|
|
|
exclude = {
|
|
|
|
-- exclude these modules, as they do not contain any written
|
|
|
|
-- documentation
|
2014-05-26 21:26:52 +02:00
|
|
|
'../lib/awful/autofocus.lua',
|
2021-10-17 05:55:21 +02:00
|
|
|
'../lib/awful/client/shape.lua',
|
2014-05-26 21:26:52 +02:00
|
|
|
'../lib/awful/dbus.lua',
|
2018-12-27 04:26:05 +01:00
|
|
|
'../lib/awful/_compat.lua',
|
2015-02-26 17:48:10 +01:00
|
|
|
'../lib/awful/init.lua',
|
2014-05-26 21:26:52 +02:00
|
|
|
'../lib/awful/remote.lua',
|
2019-06-25 05:57:45 +02:00
|
|
|
'../lib/awful/screen/dpi.lua',
|
2014-05-26 21:26:52 +02:00
|
|
|
'../lib/awful/startup_notification.lua',
|
2019-02-24 23:05:07 +01:00
|
|
|
'../lib/awful/mouse/drag_to_tag.lua',
|
2019-11-17 00:51:15 +01:00
|
|
|
'../lib/awful/permissions/_common.lua',
|
2021-10-17 05:55:21 +02:00
|
|
|
'../lib/awful/client/urgent.lua',
|
2015-02-26 17:48:10 +01:00
|
|
|
'../lib/gears/init.lua',
|
|
|
|
'../lib/wibox/layout/init.lua',
|
2016-05-23 05:56:45 +02:00
|
|
|
'../lib/wibox/container/init.lua',
|
2017-07-02 04:43:26 +02:00
|
|
|
'../lib/naughty/constants.lua',
|
|
|
|
'../lib/naughty/dbus.lua',
|
2019-06-08 01:08:05 +02:00
|
|
|
'../lib/beautiful/gtk.lua',
|
2019-10-07 01:22:17 +02:00
|
|
|
'../lib/ruled/init.lua',
|
2014-05-19 11:48:23 +02:00
|
|
|
|
2014-05-20 23:52:08 +02:00
|
|
|
-- Ignore some parts of the widget library
|
2015-02-26 16:05:47 +01:00
|
|
|
'../lib/awful/widget/init.lua',
|
2017-07-02 04:43:26 +02:00
|
|
|
'../lib/naughty/layout/init.lua',
|
2019-03-13 22:22:12 +01:00
|
|
|
'../lib/naughty/widget/init.lua',
|
|
|
|
'../lib/naughty/container/init.lua',
|
|
|
|
'../lib/naughty/list/init.lua',
|
|
|
|
'../lib/naughty/widget/_default.lua',
|
2017-11-19 06:20:56 +01:00
|
|
|
|
2018-12-25 06:49:22 +01:00
|
|
|
-- Ignore components that provide no value to users and have confusing
|
|
|
|
-- names
|
|
|
|
'../objects/button.c',
|
|
|
|
'../objects/key.c',
|
|
|
|
|
2017-11-19 06:20:56 +01:00
|
|
|
-- Deprecated classes for one years or more don't deserve entries
|
|
|
|
-- in the index
|
|
|
|
'../lib/awful/widget/graph.lua',
|
|
|
|
'../lib/awful/widget/progressbar.lua',
|
2019-06-06 10:21:08 +02:00
|
|
|
'../lib/awful/widget/textclock.lua',
|
|
|
|
'../lib/awful/wibox.lua',
|
2019-11-18 00:46:22 +01:00
|
|
|
'../lib/awful/ewmh.lua',
|
2017-11-19 06:20:56 +01:00
|
|
|
'../lib/wibox/layout/constraint.lua',
|
|
|
|
'../lib/wibox/layout/margin.lua',
|
|
|
|
'../lib/wibox/layout/mirror.lua',
|
|
|
|
'../lib/wibox/layout/rotate.lua',
|
|
|
|
'../lib/wibox/layout/scroll.lua',
|
|
|
|
'../lib/wibox/widget/background.lua',
|
2021-12-21 06:54:15 +01:00
|
|
|
'../lib/wibox/drawable.lua',
|
2014-05-19 11:48:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-08 06:35:02 +02:00
|
|
|
-- Wrap the module name for the CSS highlight.
|
|
|
|
local function wrap_modname(str, item)
|
|
|
|
if (not item.module) or str:sub(1, #item.module.name+1) ~= item.module.name.."." then return str end
|
|
|
|
|
|
|
|
return "<span class='function_modname'>"..item.module.name..".</span>"
|
|
|
|
.. str:sub(#item.module.name+2, 9999)
|
|
|
|
end
|
|
|
|
|
2019-10-01 07:44:19 +02:00
|
|
|
local named_args = {
|
2021-12-21 06:54:15 +01:00
|
|
|
[ "(args)" ] = true,
|
|
|
|
[ "([args])" ] = true,
|
|
|
|
[ "([args=nil])" ] = true,
|
|
|
|
[ "([args={}])" ] = true,
|
|
|
|
[ '(<span class="optional_param">args</span>)' ] = true,
|
|
|
|
}
|
|
|
|
|
|
|
|
local param_name_whitelist = {
|
|
|
|
Mod2 = true,
|
|
|
|
Lock = true,
|
2019-10-01 07:44:19 +02:00
|
|
|
}
|
|
|
|
|
2019-11-26 07:35:56 +01:00
|
|
|
-- Sections which are hidden by default, but visible when clicked.
|
|
|
|
local summarize = {
|
2021-12-13 20:04:32 +01:00
|
|
|
is_deprecated = {index = 1, title = "deprecated" , count = false},
|
|
|
|
emits = {index = 2, title = "signal" , count = true },
|
|
|
|
propemits = {index = 3, title = "signal" , count = true },
|
|
|
|
usebeautiful = {index = 4, title = "theme variable" , count = true },
|
|
|
|
propbeautiful = {index = 5, title = "theme variable" , count = true },
|
|
|
|
request = {index = 6, title = "permission" , count = true },
|
|
|
|
classsignal = {index = 7, title = "Class level only", count = false},
|
|
|
|
readonly = {index = 8, title = "read only" , count = false},
|
2019-11-26 07:35:56 +01:00
|
|
|
}
|
|
|
|
|
2019-11-24 09:56:19 +01:00
|
|
|
local delimiter_for_tag = {
|
2019-11-25 05:04:13 +01:00
|
|
|
usebeautiful = { "table class='widget_list' border=1", "table", "tr", "tr", {"Theme variable", "Usage"}},
|
|
|
|
propbeautiful = { "table class='widget_list' border=1", "table", "tr", "tr", {"Theme variable", "Usage"}},
|
2019-12-01 07:48:58 +01:00
|
|
|
request = { "table class='widget_list' border=1", "table", "tr", "tr", {"Class", "Permission", "Context", "Default", "Description"}},
|
2021-12-21 06:54:15 +01:00
|
|
|
sourcesignal = { "div", "div", "span", "span" }
|
|
|
|
}
|
|
|
|
|
|
|
|
--- If the title is short and descritive, there is no point to bloat it.
|
|
|
|
--
|
|
|
|
-- That test is mostly to catch empty or lazy description (such as the module
|
|
|
|
-- name and nothing else).
|
|
|
|
local short_title_whitelist = {
|
|
|
|
[ "rc.lua" ] = true,
|
|
|
|
[ "naughty.action" ] = true,
|
|
|
|
[ "naughty.layout.box" ] = true,
|
|
|
|
[ "naughty.widget.title" ] = true,
|
|
|
|
[ "theme.lua" ] = true,
|
|
|
|
[ "wibox.container.margin" ] = true,
|
|
|
|
[ "wibox.container.arcchart"] = true,
|
|
|
|
[ "wibox.widget.checkbox" ] = true,
|
|
|
|
[ "wibox.widget.imagebox" ] = true,
|
|
|
|
[ "wibox.widget.separator" ] = true,
|
|
|
|
[ "wibox.widget.progressbar"] = true,
|
|
|
|
[ "naughty" ] = true,
|
|
|
|
[ "xproperties" ] = true,
|
2019-11-24 09:56:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
-- Use the first word of the subtag content to map it to its tag.
|
|
|
|
local function sort_subtags(item, tag, subtag, values)
|
|
|
|
local ret = {}
|
|
|
|
|
|
|
|
for _, value in ipairs(values) do
|
|
|
|
local parsed = parse_custom_tags(value, {{name = "maps_to"}})
|
|
|
|
ret[parsed.maps_to.value] = ret[parsed.maps_to.value] or {}
|
|
|
|
ret[parsed.maps_to.value][#ret[parsed.maps_to.value]+1] = parsed.description
|
|
|
|
end
|
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
2019-11-26 07:35:56 +01:00
|
|
|
-- Gather a summary of the tags hidden by default .
|
|
|
|
local function generate_summary(item)
|
|
|
|
local tgs = {}
|
|
|
|
|
|
|
|
for k, v in pairs(summarize) do
|
2019-12-31 07:45:43 +01:00
|
|
|
tgs[v.index] = {title=v.title, count=0, showcount=v.count}
|
2019-11-26 07:35:56 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
for tag, value in pairs(item.tags) do
|
|
|
|
if summarize[tag] then
|
2019-12-31 08:07:22 +01:00
|
|
|
tgs[summarize[tag].index].count = #value
|
2019-11-26 07:35:56 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
local ret, has_show_more = {}, item.has_show_more or false
|
2019-11-26 07:35:56 +01:00
|
|
|
|
|
|
|
for k, v in ipairs(tgs) do
|
|
|
|
if v.count > 0 then
|
2019-12-31 08:07:22 +01:00
|
|
|
|
|
|
|
if v.count > 1 then
|
|
|
|
v.title = v.title .. "s"
|
|
|
|
end
|
|
|
|
|
2019-11-26 07:35:56 +01:00
|
|
|
ret[#ret+1] = v
|
2019-12-31 07:45:43 +01:00
|
|
|
has_show_more = v.showcount or has_show_more
|
2019-11-26 07:35:56 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
item.extra_summary = #ret > 0 and ret or nil
|
2019-12-31 07:45:43 +01:00
|
|
|
item.has_show_more = has_show_more
|
2019-11-26 07:35:56 +01:00
|
|
|
end
|
|
|
|
|
2019-11-24 09:56:19 +01:00
|
|
|
-- We have custom types, sub-types and different rendering.
|
|
|
|
--
|
|
|
|
-- To avoid added too much business logic in the template, handle this now.
|
|
|
|
-- Note that this works because the name handler is called when doing the table
|
|
|
|
-- of content, which is before any custom types is used.
|
|
|
|
local function init_custom_types(item)
|
|
|
|
if item.is_init then return end
|
|
|
|
|
2019-11-26 07:35:56 +01:00
|
|
|
generate_summary(item)
|
|
|
|
|
2019-11-25 05:59:27 +01:00
|
|
|
-- Give each item an unique identifier so the JavaScript can locate them.
|
|
|
|
item.uid, item_id = item_id, item_id + 1
|
|
|
|
|
2019-11-24 09:56:19 +01:00
|
|
|
item.delims, item.auto_usage, item.auto_params = {}, {}, {}
|
|
|
|
|
|
|
|
local to_rm = {}
|
|
|
|
|
|
|
|
for tag, values in pairs(item.tags) do
|
|
|
|
-- Remove the sub-tags so they don't get rendered as top level ones.
|
|
|
|
if named_tags[tag] and named_tags[tag].auto_usage then
|
|
|
|
item.auto_usage[tag] = sort_subtags(
|
|
|
|
item, named_tags[tag].parent, named_tags[tag], values
|
|
|
|
)
|
|
|
|
to_rm[#to_rm+1] = tag
|
|
|
|
elseif named_tags[tag] and named_tags[tag].auto_params then
|
|
|
|
item.auto_params[tag] = sort_subtags(
|
|
|
|
item, named_tags[tag].parent, named_tags[tag], values
|
|
|
|
)
|
|
|
|
to_rm[#to_rm+1] = tag
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Remove from the top-level tag list.
|
|
|
|
for _, rm in ipairs(to_rm) do
|
|
|
|
item.tags[rm] = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Set the item base class.
|
|
|
|
if item.tags["baseclass"] then
|
|
|
|
item.baseclass = item.tags["baseclass"][1]
|
|
|
|
end
|
|
|
|
|
|
|
|
if not item.baseclass and item.module then
|
|
|
|
item.baseclass = item.module.name
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Some methods and properties can be inherited from parent classes.
|
|
|
|
-- in those case, they need the explicit `@baseclass` tag.
|
|
|
|
item.inherited = item.baseclass and item.module
|
|
|
|
and item.module.name ~= item.baseclass
|
|
|
|
|
|
|
|
function item.get_delim(tag)
|
|
|
|
if delimiter_for_tag[tag] then
|
|
|
|
return delimiter_for_tag[tag][1],
|
|
|
|
delimiter_for_tag[tag][2],
|
|
|
|
delimiter_for_tag[tag][3],
|
|
|
|
delimiter_for_tag[tag][4],
|
|
|
|
delimiter_for_tag[tag][5]
|
|
|
|
else
|
|
|
|
return "ul", "ul", "li", "li", nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Allow the template to fetch the right sub-tags.
|
|
|
|
function item.get_auto_params(tag, value)
|
2021-12-21 06:54:15 +01:00
|
|
|
local extra = (item.tag_extra_data and item.tag_extra_data[tag] and item.tag_extra_data[tag][value]) or {}
|
|
|
|
|
2019-11-25 00:48:13 +01:00
|
|
|
-- Makes auto-generated subtags easier to implement.
|
|
|
|
if item.auto_params[tag.."tparam_override"] then
|
2021-12-21 06:54:15 +01:00
|
|
|
return item.auto_params[tag.."tparam_override"], named_tags[tag.."tparam"], extra
|
2019-11-25 00:48:13 +01:00
|
|
|
end
|
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
local parsed = nil
|
|
|
|
|
|
|
|
if item.parsed_tags and item.parsed_tags[tag] and item.parsed_tags[tag][value] then
|
|
|
|
parsed = item.parsed_tags[tag][value]
|
|
|
|
end
|
2019-11-24 09:56:19 +01:00
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
if not item.auto_params[tag.."tparam"] then return nil, nil, extra end
|
2019-11-24 09:56:19 +01:00
|
|
|
|
|
|
|
if parsed.name and item.auto_params[tag.."tparam"][parsed.name.value] then
|
2021-12-21 06:54:15 +01:00
|
|
|
return item.auto_params[tag.."tparam"][parsed.name.value], named_tags[tag.."tparam"], extra
|
2019-11-24 09:56:19 +01:00
|
|
|
end
|
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
return nil, nil, extra
|
2019-11-24 09:56:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
item.is_init = true
|
|
|
|
end
|
|
|
|
|
2019-06-08 06:35:02 +02:00
|
|
|
-- Wrap the arguments for the CSS highlight.
|
|
|
|
local function wrap_args(item)
|
|
|
|
if not item.args then return "" end
|
2019-10-01 07:44:19 +02:00
|
|
|
|
|
|
|
-- Display named args with `{}` and ordered args with `()`
|
|
|
|
if named_args[item.args] then
|
2021-12-17 22:07:56 +01:00
|
|
|
item.is_named_call = true
|
2019-10-01 07:44:19 +02:00
|
|
|
return "<span class='function_named_args'><b>{</b>[args]<b>}</b></span>"
|
|
|
|
end
|
|
|
|
|
2019-10-05 23:20:29 +02:00
|
|
|
local new_args = item.args:sub(2, item.args:len()-1)
|
2019-10-01 07:44:19 +02:00
|
|
|
|
|
|
|
return "<span class='function_args'> <b>(</b>"..new_args.."<b>)</b></span>"
|
2019-06-08 06:35:02 +02:00
|
|
|
end
|
|
|
|
|
2019-06-06 22:32:53 +02:00
|
|
|
-- Mimics the ldoc built-in method style, but better.
|
|
|
|
--
|
|
|
|
-- This custom renderer exists because using ldoc built-in method detection
|
|
|
|
-- turned out to be too unreliable and upstream is dead.
|
|
|
|
local function render_methods(item)
|
|
|
|
local ret = item.name
|
|
|
|
|
|
|
|
-- Some methods will have it depending on the weather. Most wont.
|
|
|
|
if not ret:find(":") then
|
|
|
|
ret = ":"..ret
|
|
|
|
end
|
|
|
|
|
2019-06-08 06:35:02 +02:00
|
|
|
return ret .. " " .. wrap_args(item)
|
2019-06-06 22:32:53 +02:00
|
|
|
end
|
|
|
|
|
2020-03-01 03:10:26 +01:00
|
|
|
-- Replace the "|" in alternative types by "or".
|
|
|
|
local function pipe_to_or(s)
|
|
|
|
s = s:gsub("|"," <i>or</i> ")
|
|
|
|
|
|
|
|
if s:sub(1,1) == "?" then
|
|
|
|
s = s:gsub("?","nil <i>or</i> ")
|
|
|
|
end
|
|
|
|
|
|
|
|
return s
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Parse the magic parameters to type in something the template eats.
|
2021-12-21 06:54:15 +01:00
|
|
|
local function sanitize_type(item)
|
2019-06-08 04:53:36 +02:00
|
|
|
for parm in ldoc.modules.iter(item.params) do
|
|
|
|
local t = item:type_of_param(parm)
|
|
|
|
|
|
|
|
-- Remove the value.
|
|
|
|
t = t:gsub("(\\[[^\\]]])","")
|
|
|
|
t = t:gsub("?","")
|
|
|
|
|
|
|
|
-- Add " or " between alternatives
|
2020-03-01 03:10:26 +01:00
|
|
|
t = pipe_to_or(t)
|
2019-06-08 04:53:36 +02:00
|
|
|
|
|
|
|
-- Fallback.
|
|
|
|
t = t == "" and parm or t
|
|
|
|
t = t == "" and "N/A" or t
|
|
|
|
|
|
|
|
item.display_type = "<span class='summary_type'>"..t.."</span>"
|
|
|
|
|
|
|
|
-- There is no value in repeating the type a second time.
|
|
|
|
if item.params.map[parm] == "" then
|
|
|
|
item.hide_params = true
|
|
|
|
end
|
|
|
|
|
|
|
|
if t ~= "N/A" then return end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- It has to be set, otherwise the table will have different col count.
|
|
|
|
item.display_type = "<span class='summary_type'>N/A</span>"
|
|
|
|
end
|
2020-03-01 03:10:26 +01:00
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
-- Detect error prone markdown formatting.
|
|
|
|
local function detect_markdown_footguns(string)
|
|
|
|
for line in string:gmatch("[^\n]*") do
|
|
|
|
if line:sub(1,4) ~= " " then
|
|
|
|
local is_tick = false
|
|
|
|
|
|
|
|
-- Detect unquoted code with 2 underscores. They will render as italic,
|
|
|
|
-- which is definitively not wanted. Add "`" to fix.
|
|
|
|
for part in line:gmatch("[^`]*") do
|
|
|
|
if not is_tick then
|
|
|
|
local count = 0
|
|
|
|
|
|
|
|
for under in part:gmatch("[^\\]_") do
|
|
|
|
count = count + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if count > 1 then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
is_tick = not is_tick
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
2020-03-01 03:10:26 +01:00
|
|
|
|
|
|
|
-- Add parentheses when there is alternative return types.
|
2021-12-21 06:54:15 +01:00
|
|
|
local function generate_return_tuple(item, group)
|
2020-03-01 03:10:26 +01:00
|
|
|
local tuple = {}
|
|
|
|
|
|
|
|
for r in group:iter() do
|
|
|
|
local type = item:return_type(r);
|
|
|
|
|
|
|
|
type = pipe_to_or(type)
|
|
|
|
|
|
|
|
if type ~= nil and type ~= "" then
|
|
|
|
tuple[#tuple+1] = type
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if #tuple == 1 then
|
|
|
|
return tuple[1]
|
|
|
|
else
|
|
|
|
local ret = "("
|
|
|
|
for i, elem in ldoc.ipairs(tuple) do
|
|
|
|
ret = ret..elem
|
|
|
|
|
|
|
|
if i ~= #tuple then
|
|
|
|
ret = ret..", "
|
|
|
|
end
|
|
|
|
end
|
|
|
|
ret = ret..")"
|
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Create a return type string.
|
2021-12-21 06:54:15 +01:00
|
|
|
local function sanitize_return_type(item)
|
2020-03-01 03:10:26 +01:00
|
|
|
|
|
|
|
local groups = item.retgroups
|
|
|
|
|
|
|
|
item.display_type = ""
|
|
|
|
|
|
|
|
if groups then
|
|
|
|
item.display_type = "<span class='summary_type'> -> "
|
|
|
|
|
|
|
|
for i,group in ldoc.ipairs(groups) do
|
|
|
|
item.display_type = item.display_type .. generate_return_tuple(
|
|
|
|
item,
|
|
|
|
group,
|
|
|
|
ldoc
|
|
|
|
)
|
|
|
|
|
|
|
|
if i ~= #groups then
|
|
|
|
item.display_type = item.display_type .. " <i>or</i> "
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
item.display_type = item.display_type .. "</span>"
|
2022-07-05 10:37:14 +02:00
|
|
|
elseif not item.tags["noreturn"] then
|
|
|
|
print(
|
|
|
|
"WARNING:", item.name, "from", item.module.name,
|
|
|
|
"doesn't have a return value or @noreturn"
|
|
|
|
)
|
2020-03-01 03:10:26 +01:00
|
|
|
end
|
2020-03-01 03:16:11 +01:00
|
|
|
|
|
|
|
item.compact_signature = true
|
2020-03-01 03:10:26 +01:00
|
|
|
end
|
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
-- Traverse the entire doc and reverse-map the links between our custom
|
|
|
|
-- tags and the content it is pointing toward. From that, we add some
|
|
|
|
-- "consumers"/"providers" tables to each (relevant) item.
|
|
|
|
local function global_init(_ldoc)
|
|
|
|
ldoc = _ldoc
|
|
|
|
|
|
|
|
if is_init then return end
|
|
|
|
is_init = true
|
|
|
|
|
|
|
|
local module_by_name = {}
|
|
|
|
|
|
|
|
-- First pass, gather the providers.
|
|
|
|
for _, mod in ipairs(ldoc.modules) do
|
|
|
|
module_by_name[mod.name] = mod
|
|
|
|
|
|
|
|
if mod.type ~= "topic" and ((not mod.summary) or mod.summary == "" or mod.summary:lower():sub(1,8) == "awesome") then
|
|
|
|
print("WARNING: Each module needs a good summary as its first line", mod.name, "doesn't")
|
|
|
|
end
|
|
|
|
|
|
|
|
local sum_count = 0
|
|
|
|
|
|
|
|
for line in (mod.summary or ""):gmatch("[^\n]*") do
|
|
|
|
sum_count = sum_count + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if sum_count > 1 and #mod.summary > 120 then
|
|
|
|
print("WARNING:", mod.name, "summary has to be only 1 line.")
|
|
|
|
end
|
|
|
|
|
|
|
|
if mod.summary and #mod.summary < 30 and not short_title_whitelist[mod.name] then
|
|
|
|
print("WARNING:", mod.name, "summary is too short.")
|
|
|
|
end
|
|
|
|
|
|
|
|
for tag, values in pairs(mod.tags) do
|
|
|
|
for _, value in ipairs(values.gmatch and {values} or values) do
|
|
|
|
-- Collect instances of some types.
|
|
|
|
if databases[tag] and databases[tag].collect then
|
|
|
|
delayed_collect[#delayed_collect+1] = {mod, mod, tag, value}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for kind, items in mod.kinds() do
|
|
|
|
for item in items() do
|
|
|
|
-- Decorate the item with our customizations.
|
|
|
|
init_custom_types(item)
|
|
|
|
|
|
|
|
-- print(item.description)
|
|
|
|
|
|
|
|
if item.summary and not detect_markdown_footguns(item.summary) then
|
|
|
|
print(
|
|
|
|
"WARNING: "..item.name.." from "..item.module.name.." seems to have"..
|
|
|
|
" ambiguous markdown in its summary, probably underscores. Please either"..
|
|
|
|
" use '`' or HTML."
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Collect instances of some types.
|
|
|
|
if databases[item.type] and databases[item.type].collect then
|
|
|
|
databases[item.type].collect(item, mod)
|
|
|
|
end
|
|
|
|
|
|
|
|
for tag, values in pairs(item.tags) do
|
|
|
|
for _, value in ipairs(values.gmatch and {values} or values) do
|
|
|
|
-- Collect instances of some types.
|
|
|
|
if databases[tag] and databases[tag].collect then
|
|
|
|
delayed_collect[#delayed_collect+1] = {item, mod, tag, value}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Lint the parameters too.
|
|
|
|
for parm in ldoc.modules.iter(item.params) do
|
|
|
|
local first = parm:match("^[ ]*(.)")
|
|
|
|
|
|
|
|
-- If the first letter of a parameter is capital, the type is probably missing.
|
|
|
|
-- That's what happen if you rename @param to @tparam without actually adding the type.
|
|
|
|
if first and first ~= first:lower() and parm:upper() ~= parm and not param_name_whitelist[parm] then
|
|
|
|
print(
|
|
|
|
"ERROR: Parameter "..parm.." from ".. item.name .. " ".. item.module.name..
|
|
|
|
" starts with a capital letter. This is forbidden."
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
for p in ldoc.modules.iter(item:subparam(parm)) do
|
|
|
|
local desc = item.params.map[p]
|
|
|
|
|
|
|
|
if not detect_markdown_footguns(desc) then
|
|
|
|
print(
|
|
|
|
"WARNING: Always use '`' to encapsulate code in the parameters." ..
|
|
|
|
p .. " from " .. item.name .. " " .. item.module.name .. " contains " ..
|
|
|
|
"some ambiguous markup. If this is a false positive, use HTML."
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- It *sometime* works, but is at risk if being interpreted as code by markdown.
|
|
|
|
if desc:match("^ [ ]+") then
|
|
|
|
print(
|
|
|
|
"WARNING: ", item.name, "from", item.module.name, "has a parameter description "..
|
|
|
|
"with leading spaces. This will not render correctly", "'"..desc.."'"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
first = desc:match("^[ ]*([a-z])")
|
|
|
|
|
|
|
|
if first and first ~= first:upper() then
|
|
|
|
print("WARNING: Sentences starts with a capital letter. Please fix", item.module.name, item.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
--TODO convert @propbeautiful to @usebeautiful and lint them
|
|
|
|
--TODO check the module summary.
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Second pass, collect the custom tags. This is delayed because
|
|
|
|
-- the tags depend on the items. Not all items have been processed if
|
|
|
|
-- this was called during the first pass. Also, collect callbacks can
|
|
|
|
-- themselves create more delayed_collect entries recursively.
|
|
|
|
for _, to_collect in ipairs(delayed_collect) do
|
|
|
|
databases[to_collect[3]].collect(to_collect[1], to_collect[2], to_collect[3], to_collect[4])
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Third pass, parse every custom tags and fill the consumers tables.
|
|
|
|
for _, mod in ipairs(ldoc.modules) do
|
|
|
|
for kind, items in mod.kinds() do
|
|
|
|
for item in items() do
|
|
|
|
for tag_name, values in pairs(item.tags) do
|
|
|
|
for _, tag in ipairs(values.gmatch and {values} or values) do
|
|
|
|
local parsed = named_tags[tag_name]
|
|
|
|
and named_tags[tag_name].params
|
|
|
|
and parse_custom_tags(tag, named_tags[tag_name].params)
|
|
|
|
|
|
|
|
-- Allow the tags to, ie, auto-generate some extra content.
|
|
|
|
if named_tags[tag_name] and named_tags[tag_name].finish_callback then
|
|
|
|
named_tags[tag_name].finish_callback(item, tag, parsed, module_by_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Save the parsed content to be used in get_auto_params.
|
|
|
|
if parsed then
|
|
|
|
item.parsed_tags = item.parsed_tags or {}
|
|
|
|
item.parsed_tags[tag_name] = item.parsed_tags[tag_name] or {}
|
|
|
|
item.parsed_tags[tag_name][tag] = parsed
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Mostly for linting.
|
|
|
|
if databases[item.type] and databases[item.type].finish then
|
|
|
|
databases[item.type].finish(item, mod, module_by_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-12-14 00:04:16 +01:00
|
|
|
-- Work around the fact that tag/awful.tag client/awful.client pages
|
|
|
|
-- are merged.
|
|
|
|
local function compare_module_name(input, module)
|
|
|
|
for _, mod in ipairs { module, "awful."..module } do
|
|
|
|
if input:sub(1, #mod) == mod then return true end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2018-10-07 01:40:36 +02:00
|
|
|
local no_prefix = {
|
2019-11-23 13:58:47 +01:00
|
|
|
property = true,
|
|
|
|
signal = true,
|
|
|
|
clientruleproperty = true,
|
2019-03-12 19:36:32 +01:00
|
|
|
deprecatedproperty = true,
|
2018-10-07 01:40:36 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:08 +02:00
|
|
|
-- These modules merge the doc of their `awful` siblings.
|
|
|
|
local coreclassmap = {
|
|
|
|
tag = "tag<span class='listplusign'> and awful.tag</span>",
|
|
|
|
screen = "screen<span class='listplusign'> and awful.screen</span>",
|
|
|
|
client = "client<span class='listplusign'> and awful.client</span>",
|
|
|
|
mouse = "mouse<span class='listplusign'> and awful.mouse</span>",
|
|
|
|
}
|
|
|
|
|
2019-06-08 01:08:05 +02:00
|
|
|
-- Add the full module name in front.
|
|
|
|
local add_mod = {
|
2019-10-27 20:39:23 +01:00
|
|
|
["function"] = true,
|
|
|
|
constructorfct = true,
|
|
|
|
constructorfct2 = true,
|
|
|
|
staticfct = true,
|
|
|
|
deprecated = true,
|
|
|
|
field = true,
|
2021-12-17 22:07:56 +01:00
|
|
|
signalhandler = true,
|
|
|
|
table = true,
|
2019-06-08 01:08:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
-- Add the arguments.
|
|
|
|
local add_args = {
|
2019-10-27 20:39:23 +01:00
|
|
|
constructorfct = true,
|
|
|
|
constructorfct2 = true,
|
|
|
|
staticfct = true,
|
2021-12-17 22:07:56 +01:00
|
|
|
signalhandler = true,
|
|
|
|
callback = true,
|
|
|
|
deprecated = true,
|
2019-06-08 01:08:05 +02:00
|
|
|
}
|
|
|
|
|
2019-06-08 04:53:36 +02:00
|
|
|
-- Add a type column to the summary and type field in the description.
|
|
|
|
local display_type = {
|
|
|
|
property = true,
|
|
|
|
beautiful = true,
|
|
|
|
field = true,
|
|
|
|
deprecatedproperty = true,
|
2019-08-18 07:53:07 +02:00
|
|
|
clientruleproperty = true,
|
|
|
|
matchingproperty = true,
|
2019-08-19 01:27:50 +02:00
|
|
|
rulecomponent = true,
|
2019-06-08 04:53:36 +02:00
|
|
|
}
|
|
|
|
|
2020-03-01 03:10:26 +01:00
|
|
|
-- Add the `-> ret_type` annotation.
|
|
|
|
local display_return_type = {
|
2021-12-08 21:24:46 +01:00
|
|
|
method = true,
|
|
|
|
deprecatedmethod = true,
|
|
|
|
staticfct = true,
|
2020-03-01 03:10:26 +01:00
|
|
|
}
|
|
|
|
|
2019-06-23 00:00:40 +02:00
|
|
|
-- Show return values.
|
|
|
|
local show_return = {
|
2021-12-08 21:24:46 +01:00
|
|
|
["function"] = true,
|
|
|
|
constructorfct = true,
|
|
|
|
constructorfct2 = true,
|
|
|
|
legacylayout = true,
|
|
|
|
staticfct = true,
|
|
|
|
method = true,
|
|
|
|
deprecated = true,
|
|
|
|
deprecatedmethod = true,
|
2019-06-23 00:00:40 +02:00
|
|
|
}
|
|
|
|
|
2019-11-10 07:12:43 +01:00
|
|
|
-- The different type of deprecation.
|
|
|
|
local is_deprecated = {
|
|
|
|
deprecated = true,
|
|
|
|
deprecatedproperty = true,
|
2021-12-08 21:24:46 +01:00
|
|
|
deprecatedmethod = true,
|
2019-11-10 07:12:43 +01:00
|
|
|
deprecatedsignal = true,
|
|
|
|
}
|
|
|
|
|
2018-05-28 19:59:22 +02:00
|
|
|
custom_display_name_handler = function(item, default_handler)
|
2021-12-21 06:54:15 +01:00
|
|
|
item.global_init = global_init
|
|
|
|
|
2021-12-13 20:04:32 +01:00
|
|
|
if is_deprecated[item.type] then
|
|
|
|
item.tags.is_deprecated = {true}
|
|
|
|
end
|
|
|
|
|
2019-11-24 09:56:19 +01:00
|
|
|
init_custom_types(item)
|
|
|
|
|
2021-12-16 18:50:52 +01:00
|
|
|
-- Do not use the default handler. It encodes the parameters using
|
|
|
|
-- the optchain convention. Not everybody is confortable with this.
|
|
|
|
-- It is also unreadable.
|
|
|
|
item.args = ""
|
|
|
|
|
|
|
|
if item.params then
|
|
|
|
item.args = "("
|
|
|
|
for key, line in ipairs(item.params) do
|
|
|
|
local name, comment = item:split_param(line)
|
|
|
|
local def = item:default_of_param(line)
|
|
|
|
if def then
|
|
|
|
item.args = item.args .. '<span class="optional_param">' .. name .. "</span>" .. (key < #item.params and ", " or "")
|
|
|
|
else
|
|
|
|
item.args = item.args .. name .. (key < #item.params and ", " or "")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
item.args = item.args .. ")"
|
|
|
|
end
|
|
|
|
|
2019-06-08 01:08:05 +02:00
|
|
|
local ret = default_handler(item)
|
|
|
|
|
2019-06-08 04:53:36 +02:00
|
|
|
-- Edit the input so the template is notified.
|
|
|
|
if display_type[item.type] then
|
|
|
|
-- Punch a hole in the sandbox and inject the `ldoc` object.
|
|
|
|
item.sanitize_type = sanitize_type
|
2020-03-01 03:10:26 +01:00
|
|
|
elseif display_return_type[item.type] then
|
|
|
|
item.sanitize_type = sanitize_return_type
|
2019-06-08 04:53:36 +02:00
|
|
|
end
|
|
|
|
|
2019-06-23 00:00:40 +02:00
|
|
|
-- LDoc hardcode the "Returns" section for "function" only, fix that.
|
|
|
|
if show_return[item.type] and item.tags["return"] then
|
|
|
|
item.ret = item.tags["return"]
|
|
|
|
item:build_return_groups()
|
|
|
|
end
|
|
|
|
|
2018-05-28 19:59:22 +02:00
|
|
|
-- Remove the "namespace" from the signals and properties
|
2018-10-07 01:40:36 +02:00
|
|
|
if no_prefix[item.type] then
|
2018-05-28 19:59:22 +02:00
|
|
|
local name = item.name:match("%.([^.]+)$")
|
|
|
|
return name ~= "" and name or item.name
|
|
|
|
end
|
|
|
|
|
2019-06-06 10:21:08 +02:00
|
|
|
-- Handle the left sidebar modules.
|
|
|
|
if item.type == "coreclassmod" and coreclassmap[item.name] then
|
|
|
|
return coreclassmap[item.name]
|
|
|
|
end
|
|
|
|
|
2019-06-08 01:08:05 +02:00
|
|
|
-- Undocumented API to make the libraries and classmod "function" section
|
|
|
|
-- more consistent. Right now some have their full awful.foo.bar while other
|
|
|
|
-- have "just" `bar`. Given we use constructors from metatables, we have no
|
|
|
|
-- choice but to use the full function name. It also makes copy/paste easier.
|
2019-06-08 01:17:02 +02:00
|
|
|
if add_mod[item.type] then
|
2021-12-14 00:04:16 +01:00
|
|
|
local is_field = item.type == "field" or item.type == "tfield"
|
|
|
|
|
2019-06-08 01:17:02 +02:00
|
|
|
if (not ret:find(".", 1, true)) and (not ret:find(":", 1, true)) then
|
|
|
|
ret = item.module.name .. "." .. ret
|
2021-12-14 00:04:16 +01:00
|
|
|
elseif is_field and not compare_module_name(ret, item.module.name) then
|
2019-06-08 01:17:02 +02:00
|
|
|
ret = item.module.name .. "." .. ret
|
|
|
|
end
|
2019-06-08 01:08:05 +02:00
|
|
|
end
|
|
|
|
|
2021-12-08 21:24:46 +01:00
|
|
|
if item.type:match("method") then
|
|
|
|
ret = render_methods(item)
|
2018-05-28 20:05:05 +02:00
|
|
|
end
|
|
|
|
|
2019-06-05 23:25:29 +02:00
|
|
|
-- Get rid of the "module:" in front of method names. It is either wrong or
|
|
|
|
-- just redundant.
|
|
|
|
ret = ret:gsub("([^:]*)(:[^:])","%2")
|
|
|
|
|
2019-06-06 07:02:31 +02:00
|
|
|
-- Undocumented API to get rid of `module.rounded_rect` rather than
|
|
|
|
-- `gears.shape.rounded_rect`
|
|
|
|
if ret:sub(1, 7) == "module." and module then
|
|
|
|
return ret:gsub("^module", item.module.name)
|
|
|
|
end
|
|
|
|
|
2019-06-07 20:59:34 +02:00
|
|
|
-- It isn't there by default.
|
2019-06-08 01:08:05 +02:00
|
|
|
if add_args[item.type] then
|
2019-06-08 06:35:02 +02:00
|
|
|
ret = ret .. " " .. wrap_args(item)
|
2019-06-06 07:02:31 +02:00
|
|
|
end
|
|
|
|
|
2019-06-08 06:35:02 +02:00
|
|
|
-- Beautify.
|
|
|
|
ret = wrap_modname(ret, item)
|
|
|
|
|
2019-06-05 23:25:29 +02:00
|
|
|
return ret
|
2018-05-28 19:59:22 +02:00
|
|
|
end
|
|
|
|
|
2015-12-12 17:42:33 +01:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|