[ADD] extension: allow to build graphs using graphviz
X-original-commit: e00b5e35c7
Part-of: odoo/documentation#1968
This commit is contained in:
parent
5aa9ba31fe
commit
1e20a49f47
3
conf.py
3
conf.py
@ -1,10 +1,12 @@
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import docutils
|
import docutils
|
||||||
from pygments.lexers import JsonLexer, XmlLexer
|
from pygments.lexers import JsonLexer, XmlLexer
|
||||||
|
from sphinx.ext import graphviz
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
import sphinx
|
import sphinx
|
||||||
|
|
||||||
@ -156,6 +158,7 @@ else:
|
|||||||
extensions += [
|
extensions += [
|
||||||
'autodoc_placeholder',
|
'autodoc_placeholder',
|
||||||
]
|
]
|
||||||
|
extensions.append('sphinx.ext.graphviz' if shutil.which('dot') else 'graphviz_placeholder')
|
||||||
|
|
||||||
todo_include_todos = False
|
todo_include_todos = False
|
||||||
|
|
||||||
|
25
extensions/graphviz_placeholder/__init__.py
Normal file
25
extensions/graphviz_placeholder/__init__.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from docutils.parsers.rst import Directive, directives
|
||||||
|
from docutils import nodes
|
||||||
|
|
||||||
|
|
||||||
|
class PlaceHolder(Directive):
|
||||||
|
""" Placeholder class for directives that must be skipped. """
|
||||||
|
|
||||||
|
has_content = True
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
node = nodes.literal_block('graphviz', '')
|
||||||
|
node += nodes.Text(
|
||||||
|
f'{self.content[0]}\n'
|
||||||
|
'> Graph not rendered because `dot` is not installed'
|
||||||
|
)
|
||||||
|
return [node]
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app):
|
||||||
|
directives.register_directive('graphviz', PlaceHolder)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'parallel_read_safe': True,
|
||||||
|
'parallel_write_safe': True
|
||||||
|
}
|
@ -971,6 +971,13 @@ header.o_main_header {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.graphviz {
|
||||||
|
overflow-x: auto;
|
||||||
|
white-space: nowrap;
|
||||||
|
img {
|
||||||
|
max-width: unset;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user