Skip to content

Commit e00b5e3

Browse files
william-andreAntoineVDV
authored andcommitted
[ADD] extension: allow to build graphs using graphviz
Part-of: #1956
1 parent 16afaf6 commit e00b5e3

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import re
22
import os
3+
import shutil
34
import sys
45
from pathlib import Path
56

67
import docutils
78
from pygments.lexers import JsonLexer, XmlLexer
9+
from sphinx.ext import graphviz
810
from sphinx.util import logging
911
import sphinx
1012

@@ -156,6 +158,7 @@
156158
extensions += [
157159
'autodoc_placeholder',
158160
]
161+
extensions.append('sphinx.ext.graphviz' if shutil.which('dot') else 'graphviz_placeholder')
159162

160163
todo_include_todos = False
161164

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from docutils.parsers.rst import Directive, directives
2+
from docutils import nodes
3+
4+
5+
class PlaceHolder(Directive):
6+
""" Placeholder class for directives that must be skipped. """
7+
8+
has_content = True
9+
10+
def run(self):
11+
node = nodes.literal_block('graphviz', '')
12+
node += nodes.Text(
13+
f'{self.content[0]}\n'
14+
'> Graph not rendered because `dot` is not installed'
15+
)
16+
return [node]
17+
18+
19+
def setup(app):
20+
directives.register_directive('graphviz', PlaceHolder)
21+
22+
return {
23+
'parallel_read_safe': True,
24+
'parallel_write_safe': True
25+
}

extensions/odoo_theme/static/style.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,13 @@ header.o_main_header {
971971
}
972972
}
973973
}
974+
.graphviz {
975+
overflow-x: auto;
976+
white-space: nowrap;
977+
img {
978+
max-width: unset;
979+
}
980+
}
974981
}
975982
}
976983
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)