class HyperlinkHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for hyperlinks. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: HyperlinkNode, file: Any) -> None: """ Generates the HTML code for a hyperlink node. :param HyperlinkNode node: The hyperlink node. :param any file: The output file. """ file.write(HyperlinkHtmlFormatter.get_html(node)) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def get_html(node: HyperlinkNode) -> str: """ Returns string with generated HTML tag. :param HyperlinkNode node: The hyperlink node. """ return Html.generate_element('a', node.get_html_attributes(), node.argument) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('hyperlink', 'html', HyperlinkHtmlFormatter)
from typing import Any from sdoc.helper.Html import Html from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.TitleNode import TitleNode from sdoc.sdoc2.NodeStore import NodeStore class TitleHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for title of SDoc document. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: TitleNode, file: Any) -> None: """ Generates HTML code for a title node. :param TitleNode node: The title node. :param any file: The output file. """ html_code = Html.generate_element('span', {}, node.argument) file.write(html_code) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('title', 'html', TitleHtmlFormatter)
Copyright 2016 Set Based IT Consultancy Licence MIT """ # ---------------------------------------------------------------------------------------------------------------------- from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter class ParagraphHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for paragraph. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates the HTML code for a paragraph node. :param sdoc.sdoc2.node.ParagraphNode.ParagraphNode node: The paragraph node. :param file file: The output file. """ file.write('<p>') HtmlFormatter.generate(self, node, file) file.write('</p>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('paragraph', 'html', ParagraphHtmlFormatter)
class HyperlinkHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for hyperlinks. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates the HTML code for a hyperlink node. :param sdoc.sdoc2.node.HyperlinkNode.HyperlinkNode node: The hyperlink node. :param file file: The output file. """ file.write(HyperlinkHtmlFormatter.get_html(node)) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def get_html(node): """ Returns string with generated HTML tag. :param sdoc.sdoc2.node.HyperlinkNode.HyperlinkNode node: The hyperlink node. :rtype: str """ return Html.generate_element('a', node.get_html_attributes(), node.argument) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('hyperlink', 'html', HyperlinkHtmlFormatter)
from typing import Any from sdoc.helper.Html import Html from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.TextNode import TextNode from sdoc.sdoc2.NodeStore import NodeStore class TextHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for text. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: TextNode, file: Any) -> None: """ Generates the HTML code for a text node. :param TextNode node: The text node. :param any file: The output file. """ file.write(Html.escape(node.argument)) HtmlFormatter.generate(self, node, file) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('TEXT', 'html', TextHtmlFormatter)
Copyright 2016 Set Based IT Consultancy Licence MIT """ # ---------------------------------------------------------------------------------------------------------------------- from sdoc.helper.Html import Html from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter class TextHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for text. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates the HTML code for a text node. :param sdoc.sdoc2.node.TextNode.TextNode node: The text node. :param file file: The output file. """ file.write(Html.escape(node.argument)) HtmlFormatter.generate(self, node, file) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('TEXT', 'html', TextHtmlFormatter)
if isinstance(col, str): data = col is_html = False else: # Generates html in nested node ('col') with specified formatter. formatter = NodeStore.get_formatter('html', col.get_command()) data = formatter.get_html(col) is_html = True return Html.generate_element('td', attributes, data, is_html) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def _get_align(align_list, column): """ Returns the align or None. :param list[str|None] align_list: The list with alignments. :param int column: The number of column. :rtype: list[str|None] | None """ if column in range(len(align_list)): return align_list[column] return None # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('table', 'html', TableHtmlFormatter)
# ------------------------------------------------------------------------------------------------------------------ @staticmethod def write_into_file(node, file): """ Writes data into opened HTML file. :param sdoc.sdoc2.node.FigureNode.FigureNode node: The figure node. :param file file: The output file. """ # Creating dicts with attributes for each type of element. figure_attributes = {'id': node.get_option_value('id')} img_attributes = {'src': node.get_option_value('src'), 'width': node.get_option_value('width'), 'height': node.get_option_value('height'), 'alt': node.caption} # Creating elements. file.write(Html.generate_tag('figure', figure_attributes)) file.write(Html.generate_void_element('img', img_attributes)) FigureHtmlFormatter._write_caption(node, file) file.write('</figure>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('figure', 'html', FigureHtmlFormatter)
Copyright 2016 Set Based IT Consultancy Licence MIT """ # ---------------------------------------------------------------------------------------------------------------------- from sdoc.helper.Html import Html from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter class VersionHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for version of SDoc document. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates HTML code for a version node. :param sdoc.sdoc2.node.VersionNode.VersionNode node: The version node. :param file file: The output file. """ html_code = Html.generate_element('span', {}, node.argument) file.write(html_code) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('version', 'html', VersionHtmlFormatter)
Generates the HTML code for an unknown node. :param Node node: The unknown node. :param any file: The output file. """ self.write_into_file(node) # ------------------------------------------------------------------------------------------------------------------ def generate_chapter(self, node: Node, file: Any) -> None: """ Generates the HTML code for an unknown node. :param Node node: The unknown node. :param any file: The output file. """ if file: self.write_into_file(node) # ------------------------------------------------------------------------------------------------------------------ def write_into_file(self, node: Node): """ Writes into opened file. :param Node node: The unknown node. """ self.error('Unknown SDoc2 command {0}'.format(node.name), node) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('unknown', 'html', UnknownHtmlFormatter)
from typing import Any from sdoc.helper.Html import Html from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.VersionNode import VersionNode from sdoc.sdoc2.NodeStore import NodeStore class VersionHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for version of SDoc document. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: VersionNode, file: Any) -> None: """ Generates HTML code for a version node. :param VersionNode node: The version node. :param any file: The output file. """ html_code = Html.generate_element('span', {}, node.argument) file.write(html_code) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('version', 'html', VersionHtmlFormatter)
""" # ---------------------------------------------------------------------------------------------------------------------- from sdoc.helper.Html import Html from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter class ItemHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for items. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates the HTML code for an item node. :param sdoc.sdoc2.node.ItemNode.ItemNode node: The item node. :param file file: The output file. """ attributes = {'id': node.get_option_value('id')} file.write('<li {0}>'.format(Html.generate_attribute('id', attributes['id']))) node.prepare_content_tree() HtmlFormatter.generate(self, node, file) file.write('</li>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('item', 'html', ItemHtmlFormatter)
# ------------------------------------------------------------------------------------------------------------------ @staticmethod def write_into_file(node: ReferenceNode, file: Any) -> None: """ Writes data into opened file. :param ReferenceNode node: The reference node. :param any file: The output file. """ file.write(ReferenceHtmlFormatter.get_html(node)) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def get_html(node: ReferenceNode) -> str: """ Returns string with generated HTML tag. :param ReferenceNode node: The reference node. """ attributes = { 'class': node.get_option_value('class'), 'href': node.get_option_value('href'), 'title': node.get_option_value('title') } return Html.generate_element('a', attributes, str(node.text)) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('ref', 'html', ReferenceHtmlFormatter)
""" SDoc Copyright 2016 Set Based IT Consultancy Licence MIT """ # ---------------------------------------------------------------------------------------------------------------------- from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter class IconDefHtmlFormatter(HtmlFormatter): """ HtmlFormatter stub for definition of the Icon. """ # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('icondef', 'html', IconDefHtmlFormatter)
from sdoc.helper.Html import Html from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.IconNode import IconNode class IconHtmlFormatter(HtmlFormatter): """ HtmlFormatter for icons in HTML representation. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates the HTML code for an icon node. :param sdoc.sdoc2.node.IconNode.IconNode node: The icon node. :param file file: The output file. """ attributes = IconNode.get_definition(node.argument) if attributes: img_element = Html.generate_void_element('img', attributes) file.write(img_element) else: NodeStore.error("There is no definition for icon with name '{}'".format(node.argument), node) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('icon', 'html', IconHtmlFormatter)
:param sdoc.sdoc2.node.DocumentNode.DocumentNode node: The document node. :param file file: The output file. """ file.write('<div class="sdoc-document-title-outer">') if node.title_node_id: title_node = in_scope(node.title_node_id) file.write(Html.generate_element('h1', {}, title_node.argument)) out_scope(title_node) file.write('<div class="sdoc-document-title-inner">') if node.date_node_id: date_node = in_scope(node.date_node_id) if date_node.argument: file.write(Html.generate_element('span', {'class': 'sdoc-document-date'}, date_node.argument)) out_scope(date_node) if node.version_node_id: version_node = in_scope(node.version_node_id) if version_node.argument: file.write(Html.generate_element('span', {'class': 'sdoc-document-version'}, version_node.argument)) out_scope(version_node) file.write('</div>') file.write('</div>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('document', 'html', DocumentHtmlFormatter)
from typing import Any from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.LineBreakNode import LineBreakNode from sdoc.sdoc2.NodeStore import NodeStore class LineBreakHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for a linebreak. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: LineBreakNode, file: Any) -> None: """ Generates the HTML code for a smile node. :param LineBreakNode node: The linebreak node. :param any file: The output file. """ file.write('<br/>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('br', 'html', LineBreakHtmlFormatter)
Copyright 2016 Set Based IT Consultancy Licence MIT """ # ---------------------------------------------------------------------------------------------------------------------- from sdoc.helper.Html import Html from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter class TitleHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for title of SDoc document. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates HTML code for a title node. :param sdoc.sdoc2.node.TitleNode.TitleNode node: The title node. :param file file: The output file. """ html_code = Html.generate_element('span', {}, node.argument) file.write(html_code) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('title', 'html', TitleHtmlFormatter)
if isinstance(cell, str): data = cell is_html = False else: # Generates html in nested node ('cell') with specified formatter. formatter = NodeStore.get_formatter('html', cell.get_command()) data = formatter.get_html(cell) is_html = True return Html.generate_element('td', attributes, data, is_html) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def _get_align(align_list: List[Optional[str]], column: int) -> Optional[List[Optional[str]]]: """ Returns the align or None. :param list[str|None] align_list: The list with alignments. :param int column: The number of column. """ if column in range(len(align_list)): return align_list[column] return None # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('table', 'html', TableHtmlFormatter)
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.NodeStore import NodeStore class IconDefHtmlFormatter(HtmlFormatter): """ HtmlFormatter stub for definition of the Icon. """ # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('icondef', 'html', IconDefHtmlFormatter)
HtmlFormatter.generate(self, node, file) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def generate_heading_node(node, file): """ Generates the HTML code for heading node. :param sdoc.sdoc2.node.HeadingNode.HeadingNode node: The heading node. :param file file: The output file. """ # Set id attribute to heading node. attributes = {'id': node.get_option_value('id')} if node.numbering: number = node.get_option_value('number') text_in_tag = '{0} {1}'.format('' if not number else number, node.argument) else: text_in_tag = '{0}'.format(node.argument) file.write(Html.generate_element('h{0:d}'.format(node.get_hierarchy_level()+2), attributes, text_in_tag)) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('part', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('chapter', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('section', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('subsection', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('sub2section', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('sub3section', 'html', HeadingHtmlFormatter)
# ------------------------------------------------------------------------------------------------------------------ @staticmethod def write_into_file(node, file): """ Writes data into opened file. :param sdoc.sdoc2.node.ReferenceNode.ReferenceNode node: The reference node. :param file file: The output file. """ file.write(ReferenceHtmlFormatter.get_html(node)) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def get_html(node): """ Returns string with generated HTML tag. :param sdoc.sdoc2.node.ReferenceNode.ReferenceNode node: The reference node. :rtype: str """ attributes = {'class': node.get_option_value('class'), 'href': node.get_option_value('href'), 'title': node.get_option_value('title')} return Html.generate_element('a', attributes, str(node.text)) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('ref', 'html', ReferenceHtmlFormatter)
TocHtmlFormatter.write_elements(item, file) elif not depth: TocHtmlFormatter.write_elements(item, file) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def write_elements(item: Dict[str, str], file: Any) -> None: """ Write the containing elements. :param dict[str,str] item: The item which we outputs. :param any file: The output file. """ class_attr = 'level{}'.format(item['level']) file.write(Html.generate_tag('li', {'class': class_attr})) file.write(Html.generate_tag('a', {'href': '#{}'.format(item['id'])})) number = item['number'] if item['numbering'] else None if number: file.write(Html.generate_element('span', {}, str(number))) file.write(' {}'.format(item['arg'])) file.write('</a>') file.write('</li>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('toc', 'html', TocHtmlFormatter)
TocHtmlFormatter.write_elements(item, file) elif not depth: TocHtmlFormatter.write_elements(item, file) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def write_elements(item, file): """ Write the containing elements. :param dict[str,str] item: The item which we outputs. :param file file: The output file. """ class_attr = 'level{}'.format(item['level']) file.write(Html.generate_tag('li', {'class': class_attr})) file.write(Html.generate_tag('a', {'href': '#{}'.format(item['id'])})) number = item['number'] if item['numbering'] else None if number: file.write(Html.generate_element('span', {}, str(number))) file.write(' {}'.format(item['arg'])) file.write('</a>') file.write('</li>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('toc', 'html', TocHtmlFormatter)
""" SDoc Copyright 2016 Set Based IT Consultancy Licence MIT """ # ---------------------------------------------------------------------------------------------------------------------- from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter class LabelHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for labels. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates the HTML code for a label node. :param sdoc.sdoc2.node.LabelNode.LabelNode node: The label node. :param file file: The output file. """ HtmlFormatter.generate(self, node, file) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('label', 'html', LabelHtmlFormatter)
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.NodeStore import NodeStore class CaptionHtmlFormatter(HtmlFormatter): """ HtmlFormatter stub generating HTML code for captions. """ # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('caption', 'html', CaptionHtmlFormatter)
from sdoc.sdoc2.node.IconNode import IconNode from sdoc.sdoc2.NodeStore import NodeStore class IconHtmlFormatter(HtmlFormatter): """ HtmlFormatter for icons in HTML representation. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: IconNode, file: Any) -> None: """ Generates the HTML code for an icon node. :param IconNode node: The icon node. :param any file: The output file. """ attributes = IconNode.get_definition(node.argument) if attributes: img_element = Html.generate_void_element('img', attributes) file.write(img_element) else: NodeStore.error( "There is no definition for icon with name '{}'".format( node.argument), node) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('icon', 'html', IconHtmlFormatter)
HtmlFormatter for generating HTML code for smile. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node, file): """ Generates the HTML code for a smile node. :param sdoc.sdoc2.node.SmileNode.SmileNode node: The smile node. :param file file: The output file. """ file.write(SmileHtmlFormatter.get_html(node)) HtmlFormatter.generate(self, node, file) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def get_html(node): """ Returns string with generated HTML tag. :param sdoc.sdoc2.node.SmileNode.SmileNode node: The smile node. :rtype: str """ return Html.generate_element('b', {}, 'SMILE') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('smile', 'html', SmileHtmlFormatter)
def generate_heading_node(node: HeadingNode, file: Any) -> None: """ Generates the HTML code for heading node. :param HeadingNode node: The heading node. :param any file: The output file. """ # Set id attribute to heading node. attributes = {'id': node.get_option_value('id')} if node.numbering: number = node.get_option_value('number') text_in_tag = '{0} {1}'.format('' if not number else number, node.argument) else: text_in_tag = '{0}'.format(node.argument) file.write( Html.generate_element( 'h{0:d}'.format(node.get_hierarchy_level() + 2), attributes, text_in_tag)) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('part', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('chapter', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('section', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('subsection', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('sub2section', 'html', HeadingHtmlFormatter) NodeStore.register_formatter('sub3section', 'html', HeadingHtmlFormatter)
from typing import Any from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.LabelNode import LabelNode from sdoc.sdoc2.NodeStore import NodeStore class LabelHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for labels. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: LabelNode, file: Any) -> None: """ Generates the HTML code for a label node. :param LabelNode node: The label node. :param any file: The output file. """ HtmlFormatter.generate(self, node, file) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('label', 'html', LabelHtmlFormatter)
class SmileHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for smile. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: SmileNode, file: Any) -> None: """ Generates the HTML code for a smile node. :param SmileNode node: The smile node. :param any file: The output file. """ file.write(SmileHtmlFormatter.get_html()) HtmlFormatter.generate(self, node, file) # ------------------------------------------------------------------------------------------------------------------ @staticmethod def get_html() -> str: """ Returns string with generated HTML tag for smile. :rtype: str """ return Html.generate_element('b', {}, 'SMILE') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('smile', 'html', SmileHtmlFormatter)
from typing import Any from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.ItemizeNode import ItemizeNode from sdoc.sdoc2.NodeStore import NodeStore class ItemizeHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for itemize. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: ItemizeNode, file: Any) -> None: """ Generates the HTML code for an itemize node. :param ItemizeNode node: The itemize node. :param any file: The output file. """ file.write('<ul>') HtmlFormatter.generate(self, node, file) file.write('</ul>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('itemize', 'html', ItemizeHtmlFormatter)
Generates the HTML code for an unknown node. :param sdoc.sdoc2.node.Node.Node node: The unknown node. :param file file: The output file. """ self.write_into_file(node) # ------------------------------------------------------------------------------------------------------------------ def generate_chapter(self, node, file): """ Generates the HTML code for an unknown node. :param sdoc.sdoc2.node.Node.Node node: The unknown node. :param file file: The output file. """ if file: self.write_into_file(node) # ------------------------------------------------------------------------------------------------------------------ def write_into_file(self, node): """ Writes into opened file. :param sdoc.sdoc2.node.Node.Node node: The unknown node. """ self.error('Unknown SDoc2 command {0}'.format(node.name), node) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('unknown', 'html', UnknownHtmlFormatter)
from typing import Any from sdoc.helper.Html import Html from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.DateNode import DateNode from sdoc.sdoc2.NodeStore import NodeStore class DateHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for date of SDoc document. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: DateNode, file: Any) -> None: """ Generates HTML code for a date node. :param DateNode node: The date node. :param any file: The output file. """ html = Html.generate_element('span', {}, node.argument) file.write(html) # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('date', 'html', DateHtmlFormatter)
from typing import Any from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter from sdoc.sdoc2.node.ParagraphNode import ParagraphNode from sdoc.sdoc2.NodeStore import NodeStore class ParagraphHtmlFormatter(HtmlFormatter): """ HtmlFormatter for generating HTML code for paragraph. """ # ------------------------------------------------------------------------------------------------------------------ def generate(self, node: ParagraphNode, file: Any) -> None: """ Generates the HTML code for a paragraph node. :param ParagraphNode node: The paragraph node. :param any file: The output file. """ file.write('<p>') HtmlFormatter.generate(self, node, file) file.write('</p>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('paragraph', 'html', ParagraphHtmlFormatter)
title_node = in_scope(node.title_node_id) file.write(Html.generate_element('h1', {}, title_node.argument)) out_scope(title_node) file.write('<div class="sdoc-document-title-inner">') if node.date_node_id: date_node = in_scope(node.date_node_id) if date_node.argument: file.write( Html.generate_element('span', {'class': 'sdoc-document-date'}, date_node.argument)) out_scope(date_node) if node.version_node_id: version_node = in_scope(node.version_node_id) if version_node.argument: file.write( Html.generate_element('span', {'class': 'sdoc-document-version'}, version_node.argument)) out_scope(version_node) file.write('</div>') file.write('</div>') # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('document', 'html', DocumentHtmlFormatter)
""" SDoc Copyright 2016 Set Based IT Consultancy Licence MIT """ # --------------------------------------------------------------------------------------------------------------------- from sdoc.sdoc2.NodeStore import NodeStore from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter class CaptionHtmlFormatter(HtmlFormatter): """ HtmlFormatter stub generating HTML code for captions. """ # ---------------------------------------------------------------------------------------------------------------------- NodeStore.register_formatter('caption', 'html', CaptionHtmlFormatter)