Skip to content

Commit

Permalink
Moved all the header tag classes from html/construct.py to html/tags/…
Browse files Browse the repository at this point in the history
…; Moved the tests for constructing all the header tags to separate files; Updated the docs accordingly
  • Loading branch information
bharadwajyarlagadda committed Sep 15, 2016
1 parent 388ff76 commit 70237ae
Show file tree
Hide file tree
Showing 13 changed files with 317 additions and 294 deletions.
12 changes: 6 additions & 6 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,27 @@ API Reference
:members:


.. autoclass:: korona.html.construct.H1
.. autoclass:: korona.html.tags.H1
:members:


.. autoclass:: korona.html.construct.H2
.. autoclass:: korona.html.tags.H2
:members:


.. autoclass:: korona.html.construct.H3
.. autoclass:: korona.html.tags.H3
:members:


.. autoclass:: korona.html.construct.H4
.. autoclass:: korona.html.tags.H4
:members:


.. autoclass:: korona.html.construct.H5
.. autoclass:: korona.html.tags.H5
:members:


.. autoclass:: korona.html.construct.H6
.. autoclass:: korona.html.tags.H6
:members:


Expand Down
12 changes: 6 additions & 6 deletions docs/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ Korona supports ``align`` attribute for ``<h1>`` tag. Korona can help you build

.. code-block:: python
from korona.html.construct import H1
from korona.html.tags import H1
attributes = {'align': 'left', 'text': 'abcd'}
Expand All @@ -772,7 +772,7 @@ Korona supports ``align`` attribute for ``<h2>`` tag. Korona can help you build

.. code-block:: python
from korona.html.construct import H2
from korona.html.tags import H2
attributes = {'align': 'left', 'text': 'abcd'}
Expand All @@ -794,7 +794,7 @@ Korona supports ``align`` attribute for ``<h3>`` tag. Korona can help you build

.. code-block:: python
from korona.html.construct import H3
from korona.html.tags import H3
attributes = {'align': 'left', 'text': 'abcd'}
Expand All @@ -816,7 +816,7 @@ Korona supports ``align`` attribute for ``<h4>`` tag. Korona can help you build

.. code-block:: python
from korona.html.construct import H4
from korona.html.tags import H4
attributes = {'align': 'left', 'text': 'abcd'}
Expand All @@ -838,7 +838,7 @@ Korona supports ``align`` attribute for ``<h5>`` tag. Korona can help you build

.. code-block:: python
from korona.html.construct import H5
from korona.html.tags import H5
attributes = {'align': 'left', 'text': 'abcd'}
Expand All @@ -860,7 +860,7 @@ Korona supports ``align`` attribute for ``<h6>`` tag. Korona can help you build

.. code-block:: python
from korona.html.construct import H6
from korona.html.tags import H6
attributes = {'align': 'left', 'text': 'abcd'}
Expand Down
132 changes: 0 additions & 132 deletions korona/html/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
form_tag,
frame_tag,
frameset_tag,
h1_tag,
h2_tag,
h3_tag,
h4_tag,
h5_tag,
h6_tag,
head_tag,
header_tag,
hr_tag,
Expand Down Expand Up @@ -538,132 +532,6 @@ def construct(self):
return frameset_tag.render(self.values)


class H1(object):
"""Class for constructing <h1> tag.
Args:
align (str): Specifies the alignment of a heading.
text (str): Specifies the <h1> text. (As in <h1>{text}</h1>)
.. versionadded:: 0.3.0
"""
def __init__(self, align=None, text=None):
self.tag = 'h1'
validate_attribute_values(tag=self.tag,
attribute_name='align',
value=align)
self.values = {'align': align, 'text': text}

def construct(self):
"""Returns the constructed tag <h1>."""
return h1_tag.render(self.values)


class H2(object):
"""Class for constructing <h2> tag.
Args:
align (str): Specifies the alignment of a heading.
text (str): Specifies the <h2> text. (As in <h2>{text}</h2>)
.. versionadded:: 0.3.0
"""
def __init__(self, align=None, text=None):
self.tag = 'h2'
validate_attribute_values(tag=self.tag,
attribute_name='align',
value=align)
self.values = {'align': align, 'text': text}

def construct(self):
"""Returns the constructed tag <h2>."""
return h2_tag.render(self.values)


class H3(object):
"""Class for constructing <h3> tag.
Args:
align (str): Specifies the alignment of a heading.
text (str): Specifies the <h3> text. (As in <h3>{text}</h3>)
.. versionadded:: 0.3.0
"""
def __init__(self, align=None, text=None):
self.tag = 'h3'
validate_attribute_values(tag=self.tag,
attribute_name='align',
value=align)
self.values = {'align': align, 'text': text}

def construct(self):
"""Returns the constructed tag <h3>."""
return h3_tag.render(self.values)


class H4(object):
"""Class for constructing <h4> tag.
Args:
align (str): Specifies the alignment of a heading.
text (str): Specifies the <h4> text. (As in <h4>{text}</h4>)
.. versionadded:: 0.3.0
"""
def __init__(self, align=None, text=None):
self.tag = 'h4'
validate_attribute_values(tag=self.tag,
attribute_name='align',
value=align)
self.values = {'align': align, 'text': text}

def construct(self):
"""Returns the constructed tag <h4>."""
return h4_tag.render(self.values)


class H5(object):
"""Class for constructing <h5> tag.
Args:
align (str): Specifies the alignment of a heading.
text (str): Specifies the <h5> text. (As in <h5>{text}</h5>)
.. versionadded:: 0.3.0
"""
def __init__(self, align=None, text=None):
self.tag = 'h5'
validate_attribute_values(tag=self.tag,
attribute_name='align',
value=align)
self.values = {'align': align, 'text': text}

def construct(self):
"""Returns the constructed tag <h5>."""
return h5_tag.render(self.values)


class H6(object):
"""Class for constructing <h6> tag.
Args:
align (str): Specifies the alignment of a heading.
text (str): Specifies the <h6> text. (As in <h6>{text}</h6>)
.. versionadded:: 0.3.0
"""
def __init__(self, align=None, text=None):
self.tag = 'h6'
validate_attribute_values(tag=self.tag,
attribute_name='align',
value=align)
self.values = {'align': align, 'text': text}

def construct(self):
"""Returns the constructed tag <h6>."""
return h6_tag.render(self.values)


class Head(object):
"""Class for constructing <head> tag.
Expand Down
2 changes: 2 additions & 0 deletions korona/html/tags/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
from .canvas import Canvas
from .caption import Caption
from .cite import Cite

from .heading import H1, H2, H3, H4, H5, H6
2 changes: 2 additions & 0 deletions korona/html/tags/button.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""Module for constructing <button> tag."""

from __future__ import absolute_import

from ..root.attributes import TAG_ATTRIBUTES
from ...templates.html.tags import button_tag

Expand Down
2 changes: 2 additions & 0 deletions korona/html/tags/canvas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""Module for constructing <canvas> tag."""

from __future__ import absolute_import

from ...lib.utils import validate_tag_attribute_value
from ...templates.html.tags import canvas_tag

Expand Down
2 changes: 2 additions & 0 deletions korona/html/tags/caption.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""Module for constructing <caption> tag."""

from __future__ import absolute_import

from ...lib.utils import validate_attribute_values
from ...templates.html.tags import caption_tag

Expand Down
2 changes: 2 additions & 0 deletions korona/html/tags/cite.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""Module for constructing <cite> tag."""

from __future__ import absolute_import

from ...templates.html.tags import cite_tag


Expand Down
Loading

0 comments on commit 70237ae

Please sign in to comment.