Cards templates for the static documentation

Introduced classes

abstract class CardCatalog

nitc :: CardCatalog

A card that displays Nit catalog related data
class CardCatalogPackage

nitc :: CardCatalogPackage

A card that displays a package from a Nit catalog
class CardCatalogStats

nitc :: CardCatalogStats

A card that displays statistics about a Nit catalog
class CardCatalogTags

nitc :: CardCatalogTags

A card that displays a list of tags
class CardCode

nitc :: CardCode

A card that displays the code of a MEntity
class CardGraph

nitc :: CardGraph

A card that displays a graph
class CardInheritance

nitc :: CardInheritance

A card about the inheritance of a MEntity
class CardLinearizationDef

nitc :: CardLinearizationDef

A card about a definition in a linearization list
class CardLinearizationList

nitc :: CardLinearizationList

A card about the linearization of a MEntity
class CardList

nitc :: CardList

A list of cards
class CardMDoc

nitc :: CardMDoc

A card that displays the content of a MDoc
class CardMEntity

nitc :: CardMEntity

A card about a mentity
class CardMdSummary

nitc :: CardMdSummary

A card that displays the summary of a Markdown document
class CardMetadata

nitc :: CardMetadata

A card that displays the metadata about a package in the Nit catalog
class CardPageHeader

nitc :: CardPageHeader

A page header
class CardSection

nitc :: CardSection

A heading section
class CardSummary

nitc :: CardSummary

A card that displays a summary of a list of cards
class CardText

nitc :: CardText

A card that display custom text data
abstract class StaticCard

nitc :: StaticCard

A card that can be rendered to HTML

All class definitions

abstract class CardCatalog

nitc $ CardCatalog

A card that displays Nit catalog related data
class CardCatalogPackage

nitc $ CardCatalogPackage

A card that displays a package from a Nit catalog
class CardCatalogStats

nitc $ CardCatalogStats

A card that displays statistics about a Nit catalog
class CardCatalogTags

nitc $ CardCatalogTags

A card that displays a list of tags
class CardCode

nitc $ CardCode

A card that displays the code of a MEntity
class CardGraph

nitc $ CardGraph

A card that displays a graph
class CardInheritance

nitc $ CardInheritance

A card about the inheritance of a MEntity
class CardLinearizationDef

nitc $ CardLinearizationDef

A card about a definition in a linearization list
class CardLinearizationList

nitc $ CardLinearizationList

A card about the linearization of a MEntity
class CardList

nitc $ CardList

A list of cards
class CardMDoc

nitc $ CardMDoc

A card that displays the content of a MDoc
class CardMEntity

nitc $ CardMEntity

A card about a mentity
class CardMdSummary

nitc $ CardMdSummary

A card that displays the summary of a Markdown document
class CardMetadata

nitc $ CardMetadata

A card that displays the metadata about a package in the Nit catalog
class CardPageHeader

nitc $ CardPageHeader

A page header
class CardSection

nitc $ CardSection

A heading section
class CardSummary

nitc $ CardSummary

A card that displays a summary of a list of cards
class CardText

nitc $ CardText

A card that display custom text data
abstract class StaticCard

nitc $ StaticCard

A card that can be rendered to HTML
package_diagram nitc::static_cards static_cards nitc::html_commands html_commands nitc::static_cards->nitc::html_commands nitc::commands_docdown commands_docdown nitc::html_commands->nitc::commands_docdown nitc::commands_parser commands_parser nitc::html_commands->nitc::commands_parser nitc::html_model html_model nitc::html_commands->nitc::html_model markdown::wikilinks wikilinks nitc::html_commands->markdown::wikilinks ...nitc::commands_docdown ... ...nitc::commands_docdown->nitc::commands_docdown ...nitc::commands_parser ... ...nitc::commands_parser->nitc::commands_parser ...nitc::html_model ... ...nitc::html_model->nitc::html_model ...markdown::wikilinks ... ...markdown::wikilinks->markdown::wikilinks nitc::static_base static_base nitc::static_base->nitc::static_cards nitc::static_structure static_structure nitc::static_structure->nitc::static_base nitc::static_structure... ... nitc::static_structure...->nitc::static_structure

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_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 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 html_commands

nitc :: html_commands

Render commands results as HTML

Children

module static_base

nitc :: static_base

Base entities shared by all the nitdoc code

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_html

nitc :: static_html

Render documentation pages as HTML
module static_index

nitc :: static_index

Manage indexing of Nit model for Nitdoc QuickSearch.
module static_structure

nitc :: static_structure

Composes the pages of the static documentation
# Cards templates for the static documentation
module static_cards

import templates::html_commands

# A card that can be rendered to HTML
#
# Basically, these cards are templates with additionnal data and behavior.
abstract class StaticCard
	super Template

	# Card title
	var title: String is writable

	# Card id
	var id: String is writable
end

# A list of cards
class CardList
	super StaticCard

	# Cards contained in this list
	var cards = new Array[StaticCard] is writable

	redef fun rendering do
		addn "<div id='{id}' class='card-list'>"
		for card in cards do
			addn card
		end
		addn "</div>"
	end
end

# Doc elements

# A card that display custom text data
class CardText
	super StaticCard
	autoinit(content)

	# Custom content from options
	var content: nullable String is writable

	redef var id = "home"
	redef var title = "Home"

	redef fun rendering do
		var content = self.content
		if content == null then return
		addn "<div>"
		addn content
		addn "</div>"
		addn "<hr/>"
	end
end

# A heading section
#
# It displays an heading at a specific level from 1 to 6.
class CardSection
	super StaticCard
	autoinit(level, title, subtitle)

	# Section heading level
	var level: Int is writable

	# Section subtitle
	var subtitle: nullable String is writable

	redef var id = title.to_cmangle is lazy

	redef fun rendering do
		addn "<h{level} id='{id}'>{title}</h{level}>"
	end
end

# A page header
class CardPageHeader
	super CardSection
	autoinit(title, subtitle)

	redef var level = 2

	redef fun rendering do
		addn "<div class='page-header'>"
		super
		var subtitle = self.subtitle
		if subtitle != null then
			addn "<p class='text-muted'>"
			addn subtitle
			addn "</p>"
		end
		addn "</div>"
	end
end

# A card that displays a summary of a list of cards
class CardSummary
	super CardList
	autoinit(no_title)

	redef var id = "summary"
	redef var title = "Summary"

	# Show the summary title
	var no_title: Bool = false is optional, writable

	redef fun rendering do
		if not no_title then
			addn "<h4>Summary</h4>"
		end
		addn "<div class='summary'>"
		addn " <ul class='list-unstyled'>"
		var sections = new Array[CardSection]
		for card in cards do
			if card isa CardSection then
				while sections.not_empty and sections.last.level >= card.level do
					sections.pop
				end
				sections.add card
			end
			var level = if sections.is_empty then 1 else sections.last.level
			if not card isa CardSection then level += 1
			addn "<li><a href='#{card.id}'><h{level}>{card.title}</h{level}></a></li>"
		end
		addn " </ul>"
		addn "</div>"
	end
end

# A card that displays the summary of a Markdown document
class CardMdSummary
	super CardMDoc
	autoinit(md_processor, headlines)

	# Markdown processor used to extract and render the content
	var md_processor: MarkdownProcessor is writable

	# Headlines found in the document
	var headlines: ArrayMap[String, HeadLine] is writable

	redef var id = "summary"
	redef var title = "Summary"

	redef fun rendering do
		addn "<h4>Summary</h4>"
		addn "<div class='summary'>"
		addn " <ul class='list-unstyled'>"
		for id, headline in headlines do
			var level = headline.level
			var title = md_processor.process(headline.title)
			addn "<li><a href='#{id}'><h{level}>{title}</h{level}></a></li>"
		end
		addn " </ul>"
		addn "</div>"
	end
end

# MEntity related cards

# A card about a mentity
#
# It displays the documentation about the model entity.
class CardMEntity
	super StaticCard
	autoinit(mentity, full_doc)

	# MEntity displayed in this card
	var mentity: MEntity is writable

	# Render the mentity full documentation?
	var full_doc = false is optional, writable

	redef var id = mentity.html_id is lazy
	redef var title = mentity.html_name is lazy

	redef fun rendering do
		addn """
		<div id='{{{id}}}' class='card'>
			<div class='card-left text-center'>
			{{{mentity.html_icon.write_to_string}}}
			</div>
			<div class='card-body'>
				<h5 class='card-heading'>
					{{{mentity.html_declaration.write_to_string}}}
				</h5>
				<p><small>{{{mentity.html_namespace.write_to_string}}}</small></p>"""
		var mdoc = mentity.mdoc_or_fallback
		if mdoc != null then
			if full_doc then
				addn mdoc.html_documentation
			else
				addn mdoc.html_synopsis
			end
		end
		addn """
			</div>
		</div>"""
	end
end

# A card that displays the content of a MDoc
class CardMDoc
	super CardMEntity
	autoinit(mentity, mdoc, full_doc)

	# MDoc to display in this card
	var mdoc: nullable MDoc is writable

	redef fun rendering do
		var mdoc = self.mdoc
		if mdoc == null then return
		addn "<div id='{id}' class='card'>"
		addn " <div class='card-body nitdoc'>"
		addn mdoc.html_documentation
		addn " </div>"
		addn "</div>"
	end
end

# A card about the inheritance of a MEntity
class CardInheritance
	super CardMEntity

	# Ancestors list
	var ancestors: nullable Array[MEntity] is writable

	# Parents list
	var parents: nullable Array[MEntity] is writable

	# Children list
	var children: nullable Array[MEntity] is writable

	# Descendants list
	var descendants: nullable Array[MEntity] is writable

	redef var id = "inh_{super}" is lazy
	redef var title = "Inheritance" is lazy

	redef fun rendering do
		var ancestors = self.ancestors
		var descendants = self.descendants
		if ancestors == null and parents == null and
			children == null and descendants == null then return

		addn "<div id='{id}' class='card'>"
		addn " <div class='card-body'>"
		if ancestors != null and ancestors.length <= 10 then
			render_list("Ancestors", ancestors)
		else
			render_list("Parents", parents)
		end
		if descendants != null and descendants.length <= 10 then
			render_list("Descendants", descendants)
		else
			render_list("Children", children)
		end
		addn " </div>"
		addn "</div>"
	end

	private fun render_list(title: String, mentities: nullable Array[MEntity]) do
		if mentities == null or mentities.is_empty then return
		addn "<h4 id='{id}'>{title}</h4>"
		addn "<ul class='list-unstyled'>"
		for mentity in mentities do
			addn html_list_item(mentity)
		end
		addn "</ul>"
	end

	private fun html_list_item(mentity: MEntity): ListItem do
		var tpl = new Template
		tpl.add mentity.html_namespace
		var comment = mentity.mdoc_or_fallback
		if comment != null then
			tpl.add ": "
			tpl.add comment.html_synopsis
		end
		return new ListItem(tpl)
	end
end

# A card about the linearization of a MEntity
class CardLinearizationList
	super CardMEntity

	# Linearization cards contained in this list
	var cards = new Array[CardLinearizationDef] is writable

	redef var id = "lin_{super}" is lazy
	redef var title = "Linearization" is lazy

	redef fun rendering do
		if cards.is_empty then return

		addn "<div id='{id}'>"
		for card in cards do
			addn card
			if card == cards.last then break
			addn "<h4 class='text-muted text-center'>"
			addn " <span class='glyphicon glyphicon-chevron-up'></span>"
			addn "</h4>"
		end
		addn "</div>"
	end
end

# A card about a definition in a linearization list
class CardLinearizationDef
	super CardCode

	# Is this card displayed by default?
	var is_active: Bool = false is optional, writable

	# Link to external code repository
	#
	# Used if `node` is null
	var url: nullable String = null is optional, writable

	redef var id = "def_{super}" is lazy
	redef var title = mentity.full_name is lazy

	redef fun rendering do
		var url = self.url

		var cin = if is_active then "in" else ""
		var active = if is_active then "active" else ""
		addn """
		<div class='card {{{active}}}' id='{{{id}}}'>
			<div class='card-body'>
				<h5>
					{{{mentity.html_icon.write_to_string}}}
					{{{mentity.html_namespace.write_to_string}}}"""
		if node != null then
			addn """
					<div class='btn-bar'>
						<button class='btn btn-link' data-toggle='collapse'
						  data-target='#{{{mentity.html_id}}}'>
							<span class='glyphicon glyphicon-console' title='Show code' />
						</button>
					</div>"""
		else if url != null then
			addn """
					<div class='btn-bar'>
						<a class='btn btn-link' href='{{{url}}}'>
							<span class='glyphicon glyphicon-console' title='Show code' />
						</a>
					</div>"""
			var mdoc = mentity.mdoc
			if mdoc != null then
				addn "<br/><br/>"
				addn mdoc.html_documentation
			end
		end
		addn "</h5>"
		if node != null then
			addn """
				<div id='{{{mentity.html_id}}}' class='collapse {{{cin}}}'>
					<pre>"""
			render_code
			addn """</pre>
					<span class='text-muted'>{{{mentity.location.to_s}}}</span>
				</div>"""
		end
		addn """
			</div>
		</div>"""
	end
end

# A card that displays the code of a MEntity
class CardCode
	super CardMEntity
	autoinit(mentity, node)

	# AST node to display in this card
	var node: nullable ANode is writable

	redef var id = "code_{super}" is lazy
	redef var title = "Code"

	redef fun rendering do
		addn "<div id='{id}' class='card'>"
		addn " <div class='card-body'>"

		if node != null then
			addn "<pre>"
			render_code
			addn "</pre>"
		end
		addn "<span class='text-muted'>{mentity.location}</span>"

		addn " </div>"
		addn "</div>"
	end

	private fun render_code do
		var node = self.node
		if node == null then return
		var hl = new HtmlightVisitor
		hl.show_infobox = false
		hl.highlight_node node
		addn hl.html
	end
end

# A card that displays a graph
class CardGraph
	super CardMEntity
	autoinit(mentity, graph)

	# Graph to display in this card
	var graph: InheritanceGraph is writable

	redef var id = "graph_{super}" is lazy
	redef var title = "Graph"

	redef fun rendering do
		addn "<div id='{id}' class='card'>"
		addn " <div class='card-body'>"
		addn "  <div class='text-center'>"
		addn graph.graph.to_svg
		addn "  </div>"
		addn " </div>"
		addn "</div>"
	end
end

# Catalog related cards

# A card that displays Nit catalog related data
abstract class CardCatalog
	super StaticCard
	autoinit(catalog)

	# Catalog used to extract the data
	var catalog: Catalog is writable
end

# A card that displays statistics about a Nit catalog
class CardCatalogStats
	super CardCatalog

	redef var id = "catalog_stats"
	redef var title = "Stats"

	redef fun rendering do
		addn "<div id='{id}' class='container-fluid'>"
		for key, value in catalog.catalog_stats.to_map do
			addn "<span class='text-muted small'>"
			addn " <strong>{value}</strong>&nbsp;<span>{key}</span>&nbsp;"
			addn "</span>"
		end
		addn "</div>"
		addn "<hr/>"
	end
end

# A card that displays a list of tags
class CardCatalogTags
	super CardCatalog

	redef var id = "catalog_tags"
	redef var title = "Tags"

	# Sorter to sort tags alphabetically
	var tags_sorter = new CatalogTagsSorter is writable

	redef fun rendering do
		var tags = catalog.tag2proj.keys.to_a
		if tags.is_empty then return
		tags_sorter.sort(tags)

		addn "<h2 id='{id}'>Tags</h2>"
		addn "<div class='container-fluid'>"
		for tag in tags do
			addn "<div class='col-xs-6 col-sm-3 col-md-2'>"
			addn " <span class='badge'>{catalog.tag2proj[tag].length}</span>"
			addn " <a href='tag_{tag.to_cmangle}.html'>{tag}</a>"
			addn "</div>"
		end
		addn "</div>"
		addn "<hr/>"
	end
end

# A card that displays a package from a Nit catalog
class CardCatalogPackage
	super CardCatalog
	super CardMEntity
	autoinit(catalog, mentity)

	redef var id = "package_{super}" is lazy

	redef fun rendering do
		var mpackage = self.mentity
		if not mpackage isa MPackage then return

		addn """
			<div id='{{{id}}}' class='card'>
			 <div class='card-left text-center'>{{{mpackage.html_icon.write_to_string}}}</div>
			 <div class='card-body' style='width: 75%'>
			  <h5 class='card-heading'>
				{{{mentity.html_declaration.write_to_string}}}
				<small>&nbsp;"""
		for tag in mpackage.metadata.tags do
			add "<span>"
			add "<a href='tag_{tag.to_cmangle}.html' class='text-muted'>{tag}</a>"
			if tag != mpackage.metadata.tags.last then addn ", "
			add "</span>"
		end
		addn """</small>
				</h5>"""
		var mdoc = mentity.mdoc_or_fallback
		if mdoc != null then
			if full_doc then
				addn mdoc.html_documentation
			else
				addn mdoc.html_synopsis
			end
		end
		addn " </div>"
		addn " <div class='card-right' style='width: 25%'>"
		for maintainer in mpackage.metadata.maintainers do
			addn maintainer.to_html
		end
		addn " <br>"
		var license = mpackage.metadata.license
		if license != null then
			addn """
				 <span class='text-muted'>
				  <a href='http://opensource.org/licenses/{{{license}}}' class='text-muted'>
				   {{{license}}}
				  </a>
				</span>"""
		end
		addn " </div>"
		addn "</div>"
	end
end

# A card that displays the metadata about a package in the Nit catalog
class CardMetadata
	super CardMEntity
	autoinit(mentity, metadata, stats, deps, clients)

	# Package metadata to display
	var metadata: MPackageMetadata is writable

	# Package stats
	var stats: MPackageStats is writable

	# Package dependencies
	var deps: Array[MPackage] is writable

	# Package clients
	var clients: Array[MPackage] is writable

	redef var id = "metadata_{super}" is lazy
	redef var title = "Metadata"

	redef fun rendering do
		for maintainer in metadata.maintainers do
			addn """
				<p class='lead'>
					{{{maintainer.to_html}}}
				</p>"""
		end
		var license = metadata.license
		if license != null then
			addn """
				<span class='text-muted'>
					<a href='http://opensource.org/licenses/{{{license}}}'>{{{license}}}</a>
					license
				</span>"""
		end

		var homepage = metadata.homepage
		var browse = metadata.browse
		var issues = metadata.issues
		if homepage != null or browse != null or issues != null then
			addn """
				<h4>Links</h4>
				<ul class='list-unstyled'>"""
			if homepage != null then addn "<li><a href='{homepage}'>Homepage</a></li>"
			if browse != null then addn "<li><a href='{browse}'>Source Code</a></li>"
			if issues != null then addn "<li><a href='{issues}'>Issues</a></li>"
			addn "</ul>"
		end

		var git = metadata.git
		var last_date = metadata.last_date
		var first_date = metadata.first_date
		if git != null then
			addn """
				<h4>Git</h4>
				<ul class='list-unstyled'>
					<li><a href='{{{git}}}'>{{{git}}}</a></li>
				</ul>
				<span class='text-muted'><b>{{{stats.commits}}}</b> commits</span>
				<br>"""
			if last_date != null then
				addn """<b class=text-muted>Last:</b> {{{last_date}}}<br>"""
			end
			if first_date != null then
				addn """<b class=text-muted>First:</b> {{{first_date}}}"""
			end
		end

		addn """
			<h4>Quality</h4>
			<ul class='list-unstyled'>
				<li>{{{stats.documentation_score}}}% documented</li>
			</ul>"""

		if metadata.tags.not_empty then
			addn "<h4>Tags</h4>"
			for tag in metadata.tags do
				addn " <a href='tag_{tag.to_cmangle}.html'>{tag}</a>"
				if tag != metadata.tags.last then add ", "
			end
		end

		if deps.not_empty then
			addn "<h4>Dependencies</h4>"
			for dep in deps do
				add dep.html_link
				if dep != deps.last then add ", "
			end
		end

		if clients.not_empty then
			addn "<h4>Clients</h4>"
			for client in clients do
				add client.html_link
				if client != clients.last then add ", "
			end
		end

		if metadata.contributors.not_empty then
			addn """
				<h4>Contributors</h4>
				<ul class='list-unstyled'>"""
			for contrib in metadata.contributors do
				addn """<li>{{{contrib.to_html}}}</li>"""
			end
			addn "</ul>"
		end

		addn """
			<h4>Stats</h4>
			<ul class='list-unstyled'>
				<li>{{{stats.mmodules}}} modules</li>
				<li>{{{stats.mclasses}}} classes</li>
				<li>{{{stats.mmethods}}} methods</li>
				<li>{{{stats.loc}}} loc</li>
			</ul>"""
	end
end
src/doc/static/static_cards.nit:15,1--675,3