if ini_path == null then return false
return ini_path.file_exists
end
+
+ # The path to `self` README.md
+ fun readme_path: nullable String do
+ var path = package_path
+ if path == null then return null
+ if not is_expanded then return null
+ return path / "README.md"
+ end
+
+ # Does `self` have a README.md file?
+ fun has_readme: Bool do
+ var readme_path = self.readme_path
+ if readme_path == null then return false
+ return readme_path.file_exists
+ end
end
# A group of modules in a package
import doc::commands::commands_main
redef class ToolContext
+
+ # nitpackage phase
+ var nitpackage_phase: Phase = new NitPackagePhase(self, null)
+
# --expand
var opt_expand = new OptionBool("Move singleton packages to their own directory", "--expand")
# --gen-makefile
var opt_gen_makefile = new OptionBool("Generate Makefile files", "--gen-makefile")
- # nitpackage phase
- var nitpackage_phase: Phase = new NitPackagePhase(self, null)
-
# --check-man
var opt_check_man = new OptionBool("Check manpages files", "--check-man")
# --gen-man
var opt_gen_man = new OptionBool("Generate manpages files", "--gen-man")
+ # --check-readme
+ var opt_check_readme = new OptionBool("Check README.md files", "--check-readme")
+
redef init do
super
option_context.add_option(opt_expand, opt_force)
option_context.add_option(opt_check_ini, opt_gen_ini)
option_context.add_option(opt_check_makefile, opt_gen_makefile)
option_context.add_option(opt_check_man, opt_gen_man)
+ option_context.add_option(opt_check_readme)
end
end
continue
end
+ # Check README.md
+ if toolcontext.opt_check_readme.value then
+ mpackage.check_readme(toolcontext)
+ continue
+ end
+
# Expand packages
if toolcontext.opt_expand.value and not mpackage.is_expanded then
var path = mpackage.expand
mmodule.gen_man(toolcontext)
end
end
+
+ # README
+
+ private fun check_readme(toolcontext: ToolContext) do
+ if not has_readme then
+ toolcontext.error(location, "No `README.md` file for `{name}`")
+ return
+ end
+ end
end
redef class MModule