[IMP] extensions: icon_role odoo ui
closes odoo/documentation#9247
X-original-commit: a39903ca12
Signed-off-by: Samuel Lieber (sali) <sali@odoo.com>
This commit is contained in:
parent
25f44f7ac2
commit
50cf2f3063
@ -216,18 +216,21 @@ Use the `command` markup to highlight a command.
|
||||
Icons
|
||||
-----
|
||||
|
||||
Use the `icon` markup to add a class name of an icon. The icon set used is *Font Awesome*. It is
|
||||
recommended to accompany an icon with a :ref:`contributing/markups/guilabel` as a descriptor,
|
||||
however, it is not mandatory.
|
||||
Use the `icon` markup to add a class name of an icon. There are two icon sets used in Odoo:
|
||||
`FontAwesome4 <https://fontawesome.com/v4/icons/>`_ and :doc:`Odoo UI
|
||||
</developer/reference/user_interface/icons>`. It is recommended to accompany an icon with a
|
||||
:ref:`contributing/markups/guilabel` as a descriptor, however, it is not mandatory.
|
||||
|
||||
.. list-table::
|
||||
:class: o-showcase-table
|
||||
|
||||
* - The graph view is represented by the :icon:`fa-bar-chart` :guilabel:`(bar chart)` icon.
|
||||
* - The graph view is represented by the :icon:`fa-area-chart` :guilabel:`(area chart)` icon. The
|
||||
pivot view is represented by the :icon:`oi-view-pivot` icon.
|
||||
|
||||
* - .. code-block:: text
|
||||
|
||||
The graph view is represented by the :icon:`fa-bar-chart` :guilabel:`(bar chart)` icon.
|
||||
The graph view is represented by the :icon:`fa-area-chart` :guilabel:`(area chart)` icon.
|
||||
The pivot view is represented by the :icon:`oi-view-pivot` icon.
|
||||
|
||||
.. _contributing/lists:
|
||||
|
||||
|
@ -115,12 +115,12 @@ def resolve(old_resolve, tree, docname, *args, **kwargs):
|
||||
def icon_role(name, rawtext, text, lineno, inliner, options=None, content=None):
|
||||
""" Implement an `icon` role for Odoo and Font Awesome icons. """
|
||||
for icon_class in text.split():
|
||||
if not icon_class.startswith('fa-'):
|
||||
if not (icon_class.startswith('fa-') or icon_class.startswith('oi-')):
|
||||
report_error = inliner.reporter.error(
|
||||
f"'{icon_class}' is not a valid icon formatting class.", lineno=lineno
|
||||
)
|
||||
error_node = inliner.problematic(rawtext, rawtext, report_error)
|
||||
return [error_node], [report_error]
|
||||
icon_html = f'<i class="{text}"></i>'
|
||||
icon_html = f'<i class="oi {text}"></i>' if text.startswith('oi-') else f'<i class="{text}"></i>'
|
||||
node = nodes.raw('', icon_html, format='html')
|
||||
return [node], []
|
||||
|
Loading…
Reference in New Issue
Block a user