nitc :: ManPage :: from_lines
init from_lines(mmodule: MModule, lines: Array[String]) do
init mmodule
var section = null
for i in [0..lines.length[ do
var line = lines[i]
if line.is_empty then continue
if line == "# NAME" then
section = "name"
continue
end
if line == "# SYNOPSIS" then
section = "synopsis"
continue
end
if line == "# OPTIONS" then
section = "options"
continue
end
if section == "name" and name == null then
name = line.trim
end
if section == "synopsis" and synopsis == null then
synopsis = line.trim
end
if section == "options" and line.has_prefix("###") then
var opts = new Array[String]
for opt in line.substring(3, line.length).trim.replace("`", "").split(",") do
opts.add opt.trim
end
var desc = ""
if i < lines.length - 1 then
desc = lines[i + 1].trim
end
options[opts] = desc
end
end
end
src/nitpackage.nit:686,2--725,4