A documentation page abstraction

Introduced properties

private var _html_url: String

nitc :: DocPage :: _html_url

Page url
private var _main_tab: DocTab

nitc :: DocPage :: _main_tab

The page main tab
private var _piwik_script: nullable PiwikScript

nitc :: DocPage :: _piwik_script

Piwik script to append in the page scripts
private var _shareurl: String

nitc :: DocPage :: _shareurl

Directory where css, js and other assets can be found
private var _tabs: Array[DocTab]

nitc :: DocPage :: _tabs

Page tab panels
private var _title: String

nitc :: DocPage :: _title

Title of this page
private var _topmenu: DocTopMenu

nitc :: DocPage :: _topmenu

Top menu template if any
fun apply_structure(doc: DocModel)

nitc :: DocPage :: apply_structure

Create the structure of this page
init defaultinit(title: String)

nitc :: DocPage :: defaultinit

fun footer: nullable Writable

nitc :: DocPage :: footer

Footer content if any
fun footer=(footer: nullable Writable)

nitc :: DocPage :: footer=

Footer content if any
fun html_url: String

nitc :: DocPage :: html_url

Page url
fun html_url=(html_url: String)

nitc :: DocPage :: html_url=

Page url
fun init_title(doc: DocModel)

nitc :: DocPage :: init_title

Build page title string
fun init_topmenu(doc: DocModel)

nitc :: DocPage :: init_topmenu

Build top menu template if any
fun main_tab: DocTab

nitc :: DocPage :: main_tab

The page main tab
protected fun main_tab=(main_tab: DocTab)

nitc :: DocPage :: main_tab=

The page main tab
fun piwik_script: nullable PiwikScript

nitc :: DocPage :: piwik_script

Piwik script to append in the page scripts
fun piwik_script=(piwik_script: nullable PiwikScript)

nitc :: DocPage :: piwik_script=

Piwik script to append in the page scripts
fun render(doc: DocModel): Writable

nitc :: DocPage :: render

Render the page as a html template
private fun render_content

nitc :: DocPage :: render_content

Renders the footer and content
private fun render_head

nitc :: DocPage :: render_head

Renders the html <head>
fun shareurl: String

nitc :: DocPage :: shareurl

Directory where css, js and other assets can be found
fun shareurl=(shareurl: String)

nitc :: DocPage :: shareurl=

Directory where css, js and other assets can be found
fun tabs: Array[DocTab]

nitc :: DocPage :: tabs

Page tab panels
protected fun tabs=(tabs: Array[DocTab])

nitc :: DocPage :: tabs=

Page tab panels
fun title: String

nitc :: DocPage :: title

Title of this page
fun title=(title: String)

nitc :: DocPage :: title=

Title of this page
fun topmenu: DocTopMenu

nitc :: DocPage :: topmenu

Top menu template if any
fun topmenu=(topmenu: DocTopMenu)

nitc :: DocPage :: topmenu=

Top menu template if any

Redefined properties

redef type SELF: DocPage

nitc $ DocPage :: SELF

Type of this instance, automatically specialized in every class
redef fun rendering

nitc :: static_html $ DocPage :: rendering

Render the whole page
redef fun to_s: String

nitc $ DocPage :: 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 _content: Array[Writable]

template :: Template :: _content

Each sub-elements
private var _html_url: String

nitc :: DocPage :: _html_url

Page url
private var _is_frozen: Bool

template :: Template :: _is_frozen

Is the template allowing more modification (add)
private var _is_writing: Bool

template :: Template :: _is_writing

Flag to avoid infinite recursivity if a template contains itself
private var _main_tab: DocTab

nitc :: DocPage :: _main_tab

The page main tab
private var _piwik_script: nullable PiwikScript

nitc :: DocPage :: _piwik_script

Piwik script to append in the page scripts
private var _render_done: Bool

template :: Template :: _render_done

Flag to avoid multiple rendering
private var _shareurl: String

nitc :: DocPage :: _shareurl

Directory where css, js and other assets can be found
private var _tabs: Array[DocTab]

nitc :: DocPage :: _tabs

Page tab panels
private var _title: String

nitc :: DocPage :: _title

Title of this page
private var _topmenu: DocTopMenu

nitc :: DocPage :: _topmenu

Top menu template if any
fun add(element: Writable)

template :: Template :: add

Append an element (String, other Template, etc.) at the end of the template.
fun add_all(elements: Collection[Writable])

template :: Template :: add_all

Append a bunch of elements at the end of the template.
fun add_list(elements: Collection[Writable], sep: Writable, last_sep: Writable)

template :: Template :: add_list

Append a bunch of elements at the end of the template with separations.
fun addn(element: Writable)

template :: Template :: addn

Append element and the end of the template then append a "\n".
fun apply_structure(doc: DocModel)

nitc :: DocPage :: apply_structure

Create the structure of this page
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.
private fun content: Array[Writable]

template :: Template :: content

Each sub-elements
private fun content=(content: Array[Writable])

template :: Template :: content=

Each sub-elements
init defaultinit(title: String)

nitc :: DocPage :: defaultinit

fun footer: nullable Writable

nitc :: DocPage :: footer

Footer content if any
fun footer=(footer: nullable Writable)

nitc :: DocPage :: footer=

Footer content if any
fun force_render

template :: Template :: force_render

Call rendering, if not already done
fun freeze

template :: Template :: freeze

Disable further modification: no more add is allowed
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.
fun html_url: String

nitc :: DocPage :: html_url

Page url
fun html_url=(html_url: String)

nitc :: DocPage :: html_url=

Page url
init init

core :: Object :: init

fun init_title(doc: DocModel)

nitc :: DocPage :: init_title

Build page title string
fun init_topmenu(doc: DocModel)

nitc :: DocPage :: init_topmenu

Build top menu template if any
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_frozen: Bool

template :: Template :: is_frozen

Is the template allowing more modification (add)
protected fun is_frozen=(is_frozen: Bool)

template :: Template :: is_frozen=

Is the template allowing more modification (add)
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 is_writing: Bool

template :: Template :: is_writing

Flag to avoid infinite recursivity if a template contains itself
private fun is_writing=(is_writing: Bool)

template :: Template :: is_writing=

Flag to avoid infinite recursivity if a template contains itself
fun main_tab: DocTab

nitc :: DocPage :: main_tab

The page main tab
protected fun main_tab=(main_tab: DocTab)

nitc :: DocPage :: main_tab=

The page main tab
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
fun new_sub: Template

template :: Template :: new_sub

Return a new basic template that is automatically added in self (using add)
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
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 piwik_script: nullable PiwikScript

nitc :: DocPage :: piwik_script

Piwik script to append in the page scripts
fun piwik_script=(piwik_script: nullable PiwikScript)

nitc :: DocPage :: piwik_script=

Piwik script to append in the page scripts
fun render(doc: DocModel): Writable

nitc :: DocPage :: render

Render the page as a html template
private fun render_content

nitc :: DocPage :: render_content

Renders the footer and content
private fun render_done: Bool

template :: Template :: render_done

Flag to avoid multiple rendering
private fun render_done=(render_done: Bool)

template :: Template :: render_done=

Flag to avoid multiple rendering
private fun render_head

nitc :: DocPage :: render_head

Renders the html <head>
protected fun rendering

template :: Template :: rendering

Service used to render the content of the template.
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun shareurl: String

nitc :: DocPage :: shareurl

Directory where css, js and other assets can be found
fun shareurl=(shareurl: String)

nitc :: DocPage :: shareurl=

Directory where css, js and other assets can be found
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun tabs: Array[DocTab]

nitc :: DocPage :: tabs

Page tab panels
protected fun tabs=(tabs: Array[DocTab])

nitc :: DocPage :: tabs=

Page tab panels
fun title: String

nitc :: DocPage :: title

Title of this page
fun title=(title: String)

nitc :: DocPage :: title=

Title of this page
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun topmenu: DocTopMenu

nitc :: DocPage :: topmenu

Top menu template if any
fun topmenu=(topmenu: DocTopMenu)

nitc :: DocPage :: topmenu=

Top menu template if any
abstract fun write_to(stream: Writer)

core :: Writable :: write_to

Write itself to a stream
fun write_to_bytes: Bytes

core :: Writable :: write_to_bytes

Like write_to but return a new Bytes (may be quite large)
fun write_to_file(filepath: String)

core :: Writable :: write_to_file

Like write_to but take care of creating the file
fun write_to_string: String

core :: Writable :: write_to_string

Like write_to but return a new String (may be quite large).
package_diagram nitc::DocPage DocPage template::Template Template nitc::DocPage->template::Template core::Writable Writable template::Template->core::Writable ...core::Writable ... ...core::Writable->core::Writable nitc::PageHome PageHome nitc::PageHome->nitc::DocPage nitc::PageMEntity PageMEntity nitc::PageMEntity->nitc::DocPage nitc::PagePerson PagePerson nitc::PagePerson->nitc::DocPage nitc::PageTag PageTag nitc::PageTag->nitc::DocPage nitc::PageMPackage PageMPackage nitc::PageMPackage->nitc::PageMEntity nitc::PageMGroup PageMGroup nitc::PageMGroup->nitc::PageMEntity nitc::PageMModule PageMModule nitc::PageMModule->nitc::PageMEntity nitc::PageMClass PageMClass nitc::PageMClass->nitc::PageMEntity nitc::PageMProperty PageMProperty nitc::PageMProperty->nitc::PageMEntity nitc::PageMPackage... ... nitc::PageMPackage...->nitc::PageMPackage nitc::PageMGroup... ... nitc::PageMGroup...->nitc::PageMGroup nitc::PageMModule... ... nitc::PageMModule...->nitc::PageMModule nitc::PageMClass... ... nitc::PageMClass...->nitc::PageMClass nitc::PageMProperty... ... nitc::PageMProperty...->nitc::PageMProperty

Ancestors

interface Object

core :: Object

The root of the class hierarchy.
interface Writable

core :: Writable

Things that can be efficienlty written to a Writer

Parents

class Template

template :: Template

Templates are simple hierarchical pieces of text used for efficient stream writing.

Children

class PageHome

nitc :: PageHome

The Nitdoc overview page that displays the nit packages catalog
abstract class PageMEntity

nitc :: PageMEntity

A DocPage documenting a MEntity
class PagePerson

nitc :: PagePerson

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

nitc :: PageTag

A page that lists the packages related to a tab

Descendants

class PageMClass

nitc :: PageMClass

A documentation page about a MClass
class PageMGroup

nitc :: PageMGroup

A documentation page about a MGroup
class PageMModule

nitc :: PageMModule

A documentation page about a MModule
class PageMPackage

nitc :: PageMPackage

A documentation page for a MPackage
class PageMProperty

nitc :: PageMProperty

A documentation page about a MProperty

Class definitions

nitc $ DocPage
# A documentation page abstraction
class DocPage

	# Title of this page
	var title: String is writable

	# Page tab panels
	#
	# Nitdoc pages are tabulated.
	# If a page has only one tab, it is presented as a single page.
	# With more than one tab, the HTML rendering process adds tab headers and
	# links.
	var tabs: Array[DocTab] = [main_tab] is lazy

	# The page main tab
	#
	# For most pages this tab is suffisent.
	# Subclasses can add more tabs.
	var main_tab = new DocTab("main", "Main")

	redef fun to_s do return title
end
src/doc/static/static_base.nit:91,1--112,3

nitc :: static_structure $ DocPage
redef class DocPage

	# Create the structure of this page
	fun apply_structure(doc: DocModel) do end
end
src/doc/static/static_structure.nit:20,1--24,3

nitc :: static_html $ DocPage
redef class DocPage
	super Template

	# Page url
	var html_url: String is writable, noinit

	# Directory where css, js and other assets can be found
	var shareurl: String is writable, noinit

	# Top menu template if any
	var topmenu: DocTopMenu is writable, noinit

	# Footer content if any
	var footer: nullable Writable = null is writable

	# Render the page as a html template
	fun render(doc: DocModel): Writable do
		# init page options
		self.shareurl = doc.share_url or else "."
		self.footer = doc.custom_footer

		# build page
		init_title(doc)
		init_topmenu(doc)

		# piwik tracking
		var tracker_url = doc.tracker_url
		var site_id = doc.piwik_site_id
		if tracker_url != null and site_id != null then
			piwik_script = new PiwikScript(tracker_url, site_id)
		end
		return self
	end

	# Build page title string
	fun init_title(doc: DocModel) do end

	# Build top menu template if any
	fun init_topmenu(doc: DocModel) do
		topmenu = new DocTopMenu

		var home = new Link("index.html", "Nitdoc")

		var custom_brand = doc.custom_brand
		if custom_brand != null then
			topmenu.brand = new Link("index.html", custom_brand)
			topmenu.items.add new ListItem(home)
		else
			topmenu.brand = home
		end
	end

	# Renders the html `<head>`
	private fun render_head do
		var css = (self.shareurl / "css").html_escape
		var vendors = (self.shareurl / "vendors").html_escape

		addn "<!DOCTYPE html>"
		addn "<head>"
		addn " <meta charset='utf-8'/>"
		addn " <link rel='stylesheet' href='{vendors}/bootstrap/css/bootstrap.min.css'/>"
		addn " <link rel='stylesheet' href='{css}/nitdoc.bootstrap.css'/>"
		addn " <link rel='stylesheet' href='{css}/nitdoc.cards.css'/>"
		addn " <link rel='stylesheet' href='{css}/nitdoc.code.css'/>"
		addn " <link rel='stylesheet' href='{css}/nitdoc.css'/>"
		addn " <link rel='stylesheet' href='{css}/nitdoc.quicksearch.css'/>"
		addn " <title>{title.html_escape}</title>"
		addn "</head>"
		add "<body>"
	end

	# Renders the footer and content
	private fun render_content do
		if tabs.is_empty then return
		if tabs.length == 1 then
			addn tabs.first
			return
		end
		addn "<ul class='nav nav-tabs'>"
		for tab in tabs do
			if tab.is_empty and not tab isa DocTabLink then continue
			addn tab.tab_link
		end
		addn "</ul>"
		addn "<div class='tab-content'>"
		for tab in tabs do
			if tab.is_empty then continue
			addn tab
		end
		addn "</div>"
	end

	# Piwik script to append in the page scripts
	var piwik_script: nullable PiwikScript = null is writable

	# Render JS scripts
	private fun render_footer do
		if footer != null then
			addn "<div class='footer'>"
			add footer.as(not null)
			addn "</div>"
		end
		var vendors = (self.shareurl / "vendors").html_escape
		var js = (self.shareurl / "js").html_escape

		addn "<script src='quicksearch-list.js'></script>"
		addn "<script src='{vendors}/jquery/jquery-1.11.1.min.js'></script>"
		addn "<script src='{vendors}/jquery/jquery-ui-1.10.4.custom.min.js'></script>"
		addn "<script src='{vendors}/bootstrap/js/bootstrap.min.js'></script>"
		addn "<script src='{js}/nitdoc.utils.js'></script>"
		addn "<script src='{js}/nitdoc.quicksearch.js'></script>"

		var piwik_script = self.piwik_script
		if piwik_script != null then
			add piwik_script
		end
		addn "</body>"
		addn "</html>"
	end

	# Render the whole page
	redef fun rendering do
		render_head
		add topmenu
		addn "<div class='container-fluid'>"
		render_content
		addn "</div>"
		render_footer
	end
end
src/doc/static/static_html.nit:21,1--150,3