Composes the pages of the static documentation

Redefined classes

redef class DocPage

nitc :: static_structure $ DocPage

A documentation page abstraction
redef abstract class MEntity

nitc :: static_structure $ MEntity

A named and possibly documented entity in the model.
redef class PageHome

nitc :: static_structure $ PageHome

The Nitdoc overview page that displays the nit packages catalog
redef class PageMClass

nitc :: static_structure $ PageMClass

A documentation page about a MClass
redef abstract class PageMEntity

nitc :: static_structure $ PageMEntity

A DocPage documenting a MEntity
redef class PageMModule

nitc :: static_structure $ PageMModule

A documentation page about a MModule
redef class PageMPackage

nitc :: static_structure $ PageMPackage

A documentation page for a MPackage
redef class PageMProperty

nitc :: static_structure $ PageMProperty

A documentation page about a MProperty
redef class PagePerson

nitc :: static_structure $ PagePerson

A page that lists the packages maintained and contributed by a person
redef class PageTag

nitc :: static_structure $ PageTag

A page that lists the packages related to a tab

All class definitions

redef class DocPage

nitc :: static_structure $ DocPage

A documentation page abstraction
redef abstract class MEntity

nitc :: static_structure $ MEntity

A named and possibly documented entity in the model.
redef class PageHome

nitc :: static_structure $ PageHome

The Nitdoc overview page that displays the nit packages catalog
redef class PageMClass

nitc :: static_structure $ PageMClass

A documentation page about a MClass
redef abstract class PageMEntity

nitc :: static_structure $ PageMEntity

A DocPage documenting a MEntity
redef class PageMModule

nitc :: static_structure $ PageMModule

A documentation page about a MModule
redef class PageMPackage

nitc :: static_structure $ PageMPackage

A documentation page for a MPackage
redef class PageMProperty

nitc :: static_structure $ PageMProperty

A documentation page about a MProperty
redef class PagePerson

nitc :: static_structure $ PagePerson

A page that lists the packages maintained and contributed by a person
redef class PageTag

nitc :: static_structure $ PageTag

A page that lists the packages related to a tab
package_diagram nitc::static_structure static_structure nitc::static_base static_base nitc::static_structure->nitc::static_base nitc::static_cards static_cards nitc::static_base->nitc::static_cards ...nitc::static_cards ... ...nitc::static_cards->nitc::static_cards nitc::static_html static_html nitc::static_html->nitc::static_structure nitc::static_index static_index nitc::static_index->nitc::static_html nitc::static_index... ... nitc::static_index...->nitc::static_index

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module abstract_tree

trees :: abstract_tree

Introduce tree structures abstraction
module actors_injection_phase

nitc :: actors_injection_phase

Injects model for the classes annotated with "is actor" so
module annotation

nitc :: annotation

Management and utilities on annotations
module array

core :: array

This module introduces the standard array structure.
module astbuilder

nitc :: astbuilder

Instantiation and transformation of semantic nodes in the AST of expressions and statements
module astutil

nitc :: astutil

Additional features on Nit AST
module auto_super_init

nitc :: auto_super_init

Computing of super-constructors that must be implicitly called at the begin of constructors.
module bintree

trees :: bintree

Binary Tree data-structure
module bitset

core :: bitset

Services to handle BitSet
module bktree

trees :: bktree

Implementation of BKTree
module bootstrap

html :: bootstrap

HTML templates for Bootstrap components.
module bytes

core :: bytes

Services for byte streams and arrays
module caching

serialization :: caching

Services for caching serialization engines
module catalog

nitc :: catalog

Basic catalog generator for Nit packages
module check_annotation

nitc :: check_annotation

Check that annotation present in the AST are either primitive or user-declared
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module commands_base

nitc :: commands_base

Documentation commands
module commands_catalog

nitc :: commands_catalog

Commands to retrieve Catalog related data
module commands_docdown

nitc :: commands_docdown

Doc down related queries
module commands_graph

nitc :: commands_graph

Graph commands
module commands_model

nitc :: commands_model

Doc commands about a Model or a MEntity
module commands_parser

nitc :: commands_parser

A parser that create DocCommand from a string
module commands_usage

nitc :: commands_usage

Commands about how mentities are used
module console

console :: console

Defines some ANSI Terminal Control Escape Sequences.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module counter

counter :: counter

Simple numerical statistical analysis and presentation
module deriving

nitc :: deriving

Injection of automatic method definitions for standard methods, based on the attributes of the classes
module digraph

graph :: digraph

Implementation of directed graphs, also called digraphs.
module div_by_zero

nitc :: div_by_zero

Detection of divisions by zero in obvious cases
module dot

dot :: dot

Dot rendering library
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module flow

nitc :: flow

Intraprocedural static flow.
module frontend

nitc :: frontend

Collect and orchestration of main frontend phases
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module glsl_validation

nitc :: glsl_validation

Check shader code within Nit modules using the tool glslangValidator
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module highlight

nitc :: highlight

Highlighting of Nit AST
module html

html :: html

HTML output facilities
module html_commands

nitc :: html_commands

Render commands results as HTML
module html_model

nitc :: html_model

Translate mentities to html blocks.
module htmlight

nitc :: htmlight

Highlighting of Nit AST with HTML
module i18n_phase

nitc :: i18n_phase

Basic support of internationalization through the generation of id-to-string tables
module ini

ini :: ini

Read and write INI configuration files
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module lexer

nitc :: lexer

Lexer and its tokens.
module lexer_work

nitc :: lexer_work

Internal algorithm and data structures for the Nit lexer
module list

core :: list

This module handle double linked lists
module literal

nitc :: literal

Parsing of literal values in the abstract syntax tree.
module loader

nitc :: loader

Loading of Nit source files
module local_var_init

nitc :: local_var_init

Verify that local variables are initialized before their usage
module location

nitc :: location

Nit source-file and locations in source-file
module markdown

markdown :: markdown

Markdown parsing.
module math

core :: math

Mathematical operations
module md5

md5 :: md5

Native MD5 digest implementation as Text::md5
module md_commands

nitc :: md_commands

Render commands results as Markdown
module mdoc

nitc :: mdoc

Documentation of model entities
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module mmodule

nitc :: mmodule

modules and module hierarchies in the metamodel
module mmodule_data

nitc :: mmodule_data

Define and retrieve data in modules
module model

nitc :: model

Classes, types and properties
module model_base

nitc :: model_base

The abstract concept of model and related common things
module model_collect

nitc :: model_collect

Collect things from the model.
module model_examples

nitc :: model_examples

Examples for Model entities
module model_index

nitc :: model_index

Search things from the Model
module modelbuilder_base

nitc :: modelbuilder_base

Load nit source files and build the associated model
module modelize

nitc :: modelize

Create a model from nit source files
module modelize_class

nitc :: modelize_class

Analysis and verification of class definitions to instantiate model element
module modelize_property

nitc :: modelize_property

Analysis and verification of property definitions to instantiate model element
module more_collections

more_collections :: more_collections

Highly specific, but useful, collections-related classes.
module mpackage

nitc :: mpackage

Modelisation of a Nit package
module native

core :: native

Native structures for text and bytes
module nitpm_shared

nitc :: nitpm_shared

Services related to the Nit package manager
module no_warning

nitc :: no_warning

Fill toolcontext information about blacklisting of warnings.
module numeric

core :: numeric

Advanced services for Numeric types
module opts

opts :: opts

Management of options on the command line
module ordered_tree

ordered_tree :: ordered_tree

Manipulation and presentation of ordered trees.
module parallelization_phase

nitc :: parallelization_phase

Phase generating threads for functions annotated with threaded annotation
module parse_annotations

nitc :: parse_annotations

Simple annotation parsing
module parser

nitc :: parser

Parser.
module parser_nodes

nitc :: parser_nodes

AST nodes of the Nit language
module parser_prod

nitc :: parser_prod

Production AST nodes full definition.
module parser_util

nitc :: parser_util

Utils and tools related to parsers and AST
module parser_work

nitc :: parser_work

Internal algorithm and data structures for the Nit parser
module phase

nitc :: phase

Phases of the processing of nit programs
module pipeline

pipeline :: pipeline

Pipelined filters and operations on iterators.
module poset

poset :: poset

Pre order sets and partial order set (ie hierarchies)
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module rbtree

trees :: rbtree

A red–black tree is a data structure which is a type of self-balancing binary search tree.
module re

core :: re

Regular expression support for all services based on Pattern
module regex_phase

nitc :: regex_phase

Check for error in regular expressions from string literals
module ropes

core :: ropes

Tree-based representation of a String.
module scope

nitc :: scope

Identification and scoping of local variables and labels.
module semantize

nitc :: semantize

Process bodies of methods in regard with the model.
module serialization

serialization :: serialization

General serialization services
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module serialization_model_phase

nitc :: serialization_model_phase

Phase generating methods (model-only) to serialize Nit objects
module simple_misc_analysis

nitc :: simple_misc_analysis

Simple vavious processing on a AST
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module static_cards

nitc :: static_cards

Cards templates for the static documentation
module stream

core :: stream

Input and output streams of characters
module tables

nitc :: tables

Module that interfaces the parsing tables.
module template

template :: template

Basic template system
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module toolcontext

nitc :: toolcontext

Common command-line tool infrastructure than handle options and error messages
module trees

trees :: trees

General module for tree data structures
module trie

trees :: trie

A trie (or prefix tree) is a datastructure used to perform prefix searches.
module typing

nitc :: typing

Intraprocedural resolution of static types and OO-services
module uml

nitc :: uml

Group head module for UML generation services
module uml_base

nitc :: uml_base

Exposes the base class for UML generation of a Model
module uml_class

nitc :: uml_class

Provides facilities of exporting a Model to a UML class diagram
module uml_module

nitc :: uml_module

Services for generation of a UML package diagram based on a Model
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O
module version

nitc :: version

This file was generated by git-gen-version.sh

Parents

module static_base

nitc :: static_base

Base entities shared by all the nitdoc code

Children

module static_html

nitc :: static_html

Render documentation pages as HTML

Descendants

module a_star-m

a_star-m

module nitdoc

nitc :: nitdoc

Generator of static API documentation for the Nit language
module static

nitc :: static

Nitdoc generation framework
module static_index

nitc :: static_index

Manage indexing of Nit model for Nitdoc QuickSearch.
# Composes the pages of the static documentation
module static_structure

import static::static_base

redef class DocPage

	# Create the structure of this page
	fun apply_structure(doc: DocModel) do end
end

redef class PageHome
	redef fun apply_structure(doc) do
		var title = doc.custom_title or else "Welcome to Nitdoc!"
		var intro = doc.custom_intro

		if intro != null then
			main_tab.content.add new CardPageHeader(title)
			main_tab.content.add new CardText(intro)
		else
			main_tab.content.add new CardPageHeader(title, "The Nit API documentation.")
		end

		main_tab.content.add new CardCatalogStats(doc.catalog)
		main_tab.content.add new CardCatalogTags(doc.catalog)

		main_tab.content.add new CardSection(2, "Packages")
		var mpackages_sorter = new CatalogScoreSorter(doc.catalog)

		var mpackages = doc.catalog.mpackages.values.to_a
		mpackages_sorter.sort mpackages
		var list = new CardList("packages", "Packages")
		for mpackage in mpackages do
			list.cards.add new CardCatalogPackage(doc.catalog, mpackage)
		end
		# TODO pagination?
		main_tab.content.add list
	end
end

redef class PageMEntity
	# Concerns to display in this page.
	var concerns: nullable ConcernsTree = null

	redef fun apply_structure(doc) do
		build_main(doc)
		build_api(doc)
		build_dependencies(doc)
	end

	# Build the main tab (the one that contains the MDoc)
	fun build_main(doc: DocModel) do
		var mentity = self.mentity

		var sq = new CmdSummary(doc.model, doc.filter, mentity,
			markdown_processor = doc.inline_processor)
		sq.init_command

		main_tab.content.add new CardMDoc(mentity, mentity.mdoc_or_fallback)

		var summary = sq.summary
		if summary != null then
			main_tab.sidebar.cards.add new CardMdSummary(headlines = summary, md_processor = doc.inline_processor)
		end
	end

	# Build the API tab
	fun build_api(doc: DocModel) do
		var summary = new CardSummary

		var title = "All definitions"
		if mentity isa MPackage then title = "All groups and modules"
		if mentity isa MGroup then title = "All subgroups and modules"
		if mentity isa MModule then title = "All class definitions"
		if mentity isa MClass or mentity isa MClassDef then title = "All properties"

		var section = new CardSection(2, title)
		api_tab.content.add section
		summary.cards.add section

		var dq = new CmdFeatures(doc.model, doc.filter, mentity)
		dq.init_command
		var mentities = dq.results
		if mentities == null then return

		var list = new CardList("api", "API")
		for m in mentities do
			var card = new CardMEntity(m)
			card.id = "api_{card.id}" # avoid id conflicts with main tab
			list.cards.add card
			summary.cards.add card
		end
		api_tab.content.add list

		if summary.cards.not_empty then
			api_tab.sidebar.cards.add summary
		end
	end

	# Build the dependencies tab
	fun build_dependencies(doc: DocModel) do
		var summary = new CardSummary

		var model = doc.model
		var mainmodule = doc.mainmodule
		var filter = doc.filter

		if not doc.no_dot then
			var gq = new CmdInheritanceGraph(model, mainmodule, filter, mentity)
			gq.init_command
			var graph = gq.graph
			if graph != null then
				graph.draw(2, 2)
				dep_tab.content.add new CardGraph(mentity, graph)
			end
		end

		# No inheritance lists for `Object`
		if mentity isa MClass and mentity.name == "Object" then return

		var inh = new HashMap[String, CmdEntityList]
		inh["Ancestors"] = new CmdAncestors(model, mainmodule, filter, mentity, parents = false)
		inh["Parents"] = new CmdParents(model, mainmodule, filter, mentity)
		inh["Children"] = new CmdChildren(model, mainmodule, filter, mentity)
		inh["Descendants"] = new CmdDescendants(model, mainmodule, filter, mentity, children = false)

		for title, cmd in inh do
			cmd.init_command
			var results = cmd.results
			if results == null or results.is_empty then continue
			var section = new CardSection(3, title)
			dep_tab.content.add section
			summary.cards.add section

			var list = new CardList("inh", "Inheritance")
			for mentity in results do
				var card = new CardMEntity(mentity)
				list.cards.add card
				summary.cards.add card
			end
			dep_tab.content.add list
		end

		if summary.cards.not_empty then
			dep_tab.sidebar.cards.add summary
		end
	end

	# Build the code panel
	fun build_code(doc: DocModel) do
		var code_url = doc.code_url

		if not doc.no_code then
			var cq = new CmdEntityCode(doc.model, doc.modelbuilder, doc.filter, mentity)
			cq.init_command

			var code = cq.node
			if code == null then return
			code_tab.content.add new CardCode(mentity, code)
		else if doc.code_url != null then
			code_tab = new DocTabLink("code", "Code", "console", mentity.source_url(code_url))
		end
	end

	# Build the linearization panel
	fun build_linearization(doc: DocModel) do
		var summary = new CardSummary

		var lq = new CmdLinearization(doc.model, doc.mainmodule, doc.filter, mentity)
		lq.init_command

		var mentities = lq.results
		if mentities == null then return

		if mentity isa MClass or mentity isa MClassDef then
			if mentity.name == "Object" then return # No linearization for `Object`
			if mentity.name == "Sys" then return # No linearization for `Sys`
			var section = new CardSection(2, "Class definitions")
			lin_tab.content.add section
			summary.cards.add section
		else if mentity isa MProperty or mentity isa MPropDef then
			if mentity.name == "init" then return # No linearization for `init`
			if mentity.name == "SELF" then return # No linearization for `SELF`
			if mentity.name == "to_s" then return # No linearization for `to_s`
			var section = new CardSection(2, "Property definitions")
			lin_tab.content.add section
			summary.cards.add section
		end

		var list = new CardLinearizationList(mentity)
		for m in mentities do
			var url = mentity.source_url(doc.code_url)
			var node = doc.modelbuilder.mentity2node(m)
			if node == null then continue
			if doc.no_code then node = null
			if m == mentity or
			  (m isa MClassDef and m.is_intro) or
			  (m isa MPropDef and m.is_intro) then
				var card = new CardLinearizationDef(m, node, is_active = true, url)
				list.cards.add card
				summary.cards.add card
			else
				var card = new CardLinearizationDef(m, node, is_active = false, url)
				list.cards.add card
				summary.cards.add card
			end
		end
		lin_tab.content.add list

		if summary.cards.not_empty then
			lin_tab.sidebar.cards.add summary
		end
	end
end

redef class PageMPackage
	redef fun build_main(doc) do
		super
		main_tab.metadata.cards.add new CardMetadata(mentity, mentity.metadata,
			doc.catalog.mpackages_stats[mentity],
			doc.catalog.deps.successors(mentity).to_a,
			doc.catalog.deps.predecessors(mentity).to_a)
	end
end

redef class PageMModule
	redef fun apply_structure(doc) do
		super
		build_code(doc)
	end

	redef fun build_main(doc) do
		super

		var summary = new CardSummary(no_title = true)

		# Intros
		var cmd: CmdEntities = new CmdIntros(doc.model, doc.mainmodule, doc.filter, mentity)
		cmd.init_command
		var intros = cmd.results
		if intros != null and intros.not_empty then
			var section = new CardSection(3, "Introduced classes")
			main_tab.content.add section
			summary.cards.add section
			var cards = new CardList("intros", "Intros")
			for intro in intros do
				var card = new CardMEntity(intro)
				summary.cards.add card
				cards.cards.add card
			end
			main_tab.content.add cards
		end

		# Redefs
		cmd = new CmdRedefs(doc.model, doc.mainmodule, doc.filter, mentity)
		cmd.init_command
		var redefs = cmd.results
		if redefs != null and redefs.not_empty then
			var section = new CardSection(3, "Redefined classes")
			main_tab.content.add section
			summary.cards.add section
			var cards = new CardList("redefs", "Redefs")
			for prop in redefs do
				var card = new CardMEntity(prop)
				summary.cards.add card
				cards.cards.add card
			end
			main_tab.content.add cards
		end

		main_tab.sidebar.cards.add summary
	end
end

redef class PageMClass
	redef fun apply_structure(doc) do
		super
		build_code(doc)
		build_linearization(doc)
	end

	redef fun build_main(doc) do
		super

		var summary = new CardSummary(no_title = true)

		# Intros
		var cmd: CmdEntities = new CmdIntros(doc.model, doc.mainmodule, doc.filter, mentity)
		cmd.init_command
		var intros = cmd.results
		if intros != null and intros.not_empty then
			var section = new CardSection(3, "Introduced properties")
			main_tab.content.add section
			summary.cards.add section
			var cards = new CardList("intros", "Intros")
			for intro in intros do
				var card = new CardMEntity(intro)
				summary.cards.add card
				cards.cards.add card
			end
			main_tab.content.add cards
		end

		# Redefs
		cmd = new CmdRedefs(doc.model, doc.mainmodule, doc.filter, mentity)
		cmd.init_command
		var redefs = cmd.results
		if redefs != null and redefs.not_empty then
			var section = new CardSection(3, "Redefined properties")
			main_tab.content.add section
			summary.cards.add section
			var cards = new CardList("redefs", "Redefs")
			for prop in redefs do
				var card = new CardMEntity(prop)
				summary.cards.add card
				cards.cards.add card
			end
			main_tab.content.add cards
		end

		# Expand summary
		main_tab.sidebar.cards.add summary
	end

	redef fun build_api(doc) do
		var summary = new CardSummary

		var section = new CardSection(2, "All properties")
		api_tab.content.add section
		summary.cards.add section

		var dq = new CmdAllProps(doc.model, doc.mainmodule, doc.filter, mentity)
		dq.init_command
		var mentities = dq.results
		if mentities == null then return

		var list = new CardList("api", "API")
		for m in mentities do
			var card = new CardMEntity(m)
			list.cards.add card
			summary.cards.add card
		end
		api_tab.content.add list

		if summary.cards.not_empty then
			api_tab.sidebar.cards.add summary
		end
	end
end

redef class PageMProperty
	redef fun apply_structure(doc) do
		super
		build_code(doc)
		build_linearization(doc)
	end
end

redef class PagePerson
	redef fun apply_structure(doc) do
		var mpackages_sorter = new CatalogScoreSorter(doc.catalog)
		main_tab.content.add new CardPageHeader(person.name, person.email)

		var maint = doc.catalog.maint2proj[person]
		mpackages_sorter.sort maint
		var mlist = new CardList("maintained", "Maintained")
		for mpackage in maint do
			mlist.cards.add new CardCatalogPackage(doc.catalog, mpackage)
		end

		# TODO pagination?
		if maint.not_empty then
			main_tab.content.add new CardSection(3, "{maint.length} maintained packages")
			main_tab.content.add mlist
		end

		var contrib = doc.catalog.contrib2proj[person]
		mpackages_sorter.sort contrib
		var clist = new CardList("contribs", "Contributed")
		for mpackage in contrib do
			clist.cards.add new CardCatalogPackage(doc.catalog, mpackage)
		end

		# TODO pagination?
		if contrib.not_empty then
			main_tab.content.add new CardSection(3, "{contrib.length} contributed packages")
			main_tab.content.add clist
		end
	end
end

redef class PageTag
	redef fun apply_structure(doc) do
		var mpackages_sorter = new CatalogScoreSorter(doc.catalog)
		main_tab.content.add new CardPageHeader(tag)

		var mpackages = doc.catalog.tag2proj[tag]
		mpackages_sorter.sort mpackages
		var list = new CardList("packages", "Packages")
		for mpackage in mpackages do
			list.cards.add new CardCatalogPackage(doc.catalog, mpackage)
		end

		# TODO pagination?
		main_tab.content.add new CardSection(3, "{mpackages.length} packages")
		main_tab.content.add list
	end
end

redef class MEntity
	# Render a HTML link for the MEntity location
	private fun source_url(url_pattern: nullable String): String do
		var location = self.location
		var file = location.file

		if file == null then return location.to_s
		if url_pattern == null then return file.filename.simplify_path

		var url = url_pattern
		url = url.replace("%f", file.filename.simplify_path)
		url = url.replace("%l", location.line_start.to_s)
		url = url.replace("%L", location.line_end.to_s)
		return url.simplify_path
	end
end
src/doc/static/static_structure.nit:15,1--439,3