Introduced properties

private var _mmodule: MModule

nitc :: ManPage :: _mmodule

private var _name: nullable String

nitc :: ManPage :: _name

private var _synopsis: nullable String

nitc :: ManPage :: _synopsis

init defaultinit(mmodule: MModule)

nitc :: ManPage :: defaultinit

private fun diff(toolcontext: ToolContext, ref: ManPage)

nitc :: ManPage :: diff

private init from_file(mmodule: MModule, file: String)

nitc :: ManPage :: from_file

private init from_lines(mmodule: MModule, lines: Array[String])

nitc :: ManPage :: from_lines

private init from_string(mmodule: MModule, string: String)

nitc :: ManPage :: from_string

private fun mmodule: MModule

nitc :: ManPage :: mmodule

private fun mmodule=(mmodule: MModule)

nitc :: ManPage :: mmodule=

private fun name: nullable String

nitc :: ManPage :: name

private fun name=(name: nullable String)

nitc :: ManPage :: name=

private fun options: HashMap[Array[String], String]

nitc :: ManPage :: options

private fun options=(options: HashMap[Array[String], String])

nitc :: ManPage :: options=

private fun synopsis: nullable String

nitc :: ManPage :: synopsis

private fun synopsis=(synopsis: nullable String)

nitc :: ManPage :: synopsis=

Redefined properties

redef type SELF: ManPage

nitc $ ManPage :: SELF

Type of this instance, automatically specialized in every class
redef fun to_s: String

nitc $ ManPage :: to_s

User readable representation of self.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _mmodule: MModule

nitc :: ManPage :: _mmodule

private var _name: nullable String

nitc :: ManPage :: _name

private var _synopsis: nullable String

nitc :: ManPage :: _synopsis

protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
init defaultinit(mmodule: MModule)

nitc :: ManPage :: defaultinit

private fun diff(toolcontext: ToolContext, ref: ManPage)

nitc :: ManPage :: diff

private init from_file(mmodule: MModule, file: String)

nitc :: ManPage :: from_file

private init from_lines(mmodule: MModule, lines: Array[String])

nitc :: ManPage :: from_lines

private init from_string(mmodule: MModule, string: String)

nitc :: ManPage :: from_string

fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
private fun mmodule: MModule

nitc :: ManPage :: mmodule

private fun mmodule=(mmodule: MModule)

nitc :: ManPage :: mmodule=

private fun name: nullable String

nitc :: ManPage :: name

private fun name=(name: nullable String)

nitc :: ManPage :: name=

private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
private fun options: HashMap[Array[String], String]

nitc :: ManPage :: options

private fun options=(options: HashMap[Array[String], String])

nitc :: ManPage :: options=

fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
private fun synopsis: nullable String

nitc :: ManPage :: synopsis

private fun synopsis=(synopsis: nullable String)

nitc :: ManPage :: synopsis=

intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::nitpackage::ManPage ManPage core::Object Object nitc::nitpackage::ManPage->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

nitc $ ManPage
private class ManPage
	var mmodule: MModule
	var name: nullable String is noinit
	var synopsis: nullable String is noinit
	var options = new HashMap[Array[String], String]

	init from_file(mmodule: MModule, file: String) do
		from_lines(mmodule, file.to_path.read_lines)
	end

	init from_string(mmodule: MModule, string: String) do
		from_lines(mmodule, string.split("\n"))
	end

	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

	fun diff(toolcontext: ToolContext, ref: ManPage) do
		if name != ref.name then
			toolcontext.warning(mmodule.location, "diff-man",
				"Warning: outdated man description. " +
				"Expected `{ref.name or else ""}` got `{name or else ""}`.")
		end
		if synopsis != ref.synopsis then
			toolcontext.warning(mmodule.location, "diff-man",
				"Warning: outdated man synopsis. " +
				"Expected `{ref.synopsis or else ""}` got `{synopsis or else ""}`.")
		end
		for name, desc in options do
			if not ref.options.has_key(name) then
				toolcontext.warning(mmodule.location, "diff-man",
					"Warning: unknown man option `{name}`.`")
				continue
			end
			var ref_desc = ref.options[name]
			if desc != ref_desc then
				toolcontext.warning(mmodule.location, "diff-man",
					"Warning: outdated man option description. Expected `{ref_desc}` got `{desc}`.")
			end
		end
		for ref_name, ref_desc in ref.options do
			if not options.has_key(ref_name) then
				toolcontext.warning(mmodule.location, "diff-man",
					"Warning: missing man option `{ref_name}`.`")
			end
		end
	end

	redef fun to_s do
		var tpl = new Template
		tpl.addn "# NAME"
		tpl.addn name or else ""
		tpl.addn "# SYNOPSIS"
		tpl.addn synopsis or else ""
		tpl.addn "# OPTIONS"
		for name, desc in options do
			tpl.addn " * {name}: {desc}"
		end
		return tpl.write_to_string
	end
end
src/nitpackage.nit:672,1--770,3