mkdocs-nodegraph 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ import logging
2
+ import os
3
+ import re
4
+ from mkdocs.config.config_options import Type
5
+ import mkdocs.plugins
6
+ from .nodegraph import generate_graph
7
+
8
+
9
+ log = logging.getLogger(__name__)
10
+ base_path = os.path.dirname(os.path.abspath(__file__))
11
+
12
+
13
+ class GraphViewPlugin(mkdocs.plugins.BasePlugin):
14
+ config_scheme = (
15
+ ('graphfile', Type(str, default='nodegraph.html')),
16
+ )
17
+
18
+ def get_config_graphfile(self):
19
+ graphfile = self.config['graphfile']
20
+ graphfile = graphfile.replace('\\', '/')
21
+ rgx = re.search('\w.+', graphfile)
22
+ if rgx:
23
+ return rgx.group()
24
+ else:
25
+ return graphfile
26
+
27
+ def on_post_page(self, output, page, config):
28
+ dest_path = page.file.dest_path
29
+ dest_path = dest_path.replace("/", "\\") if "/" in dest_path else dest_path
30
+ level_count = dest_path.count('\\')
31
+ prefix = ""
32
+ if level_count:
33
+ prefix = (level_count*"../")
34
+ graphfile = prefix + self.get_config_graphfile()
35
+ my_html = f'''<form class="md-header__option" data-md-component="palette">
36
+ <a href="{graphfile}" class="md-header__button md-graph" data-md-component="logo">
37
+ <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
38
+ <path d="M17.5 3a3.5 3.5 0 0 0-3.456 4.06L8.143 9.704a3.5 3.5 0 1 0-.01 4.6l5.91 2.65a3.5 3.5 0 1 0 .863-1.805l-5.94-2.662a3.53 3.53 0 0 0 .002-.961l5.948-2.667A3.5 3.5 0 1 0 17.5 3Z"/>
39
+ </svg>
40
+ </a>
41
+ '''
42
+ output = output.replace('<form class="md-header__option" data-md-component="palette">', my_html)
43
+
44
+ html_filename = page.file.name
45
+ graphfile_basename = os.path.basename(graphfile)
46
+ graphfilename = graphfile_basename.rsplit('.', 1)[0] if '.' in graphfile_basename else graphfile_basename
47
+ if html_filename == graphfilename:
48
+ script = """
49
+ <script>
50
+ document.addEventListener('DOMContentLoaded', function() {
51
+ const footerMetas = document.querySelectorAll('.md-footer-meta.md-typeset');
52
+ footerMetas.forEach(function(element) {
53
+ element.remove();
54
+ });
55
+
56
+ document.querySelector('.md-typeset').style.fontSize = '0px';
57
+ document.querySelector('.md-typeset').style.margin = '0px';
58
+ });
59
+
60
+ var right_sidebar = document.getElementsByClassName('md-sidebar md-sidebar--secondary');
61
+ if (right_sidebar.length > 0) {
62
+ right_sidebar[0].style.width = '0px';
63
+ }
64
+
65
+ </script>
66
+ """
67
+ # Insert the script before the closing </body> tag
68
+ output = output.replace('</body>', f'{script} </body>')
69
+
70
+ return output
71
+
72
+ def on_post_build(self, config, **kwargs):
73
+ docs_dir = config["docs_dir"]
74
+ site_dir = config['site_dir']
75
+ config_graphfile = self.get_config_graphfile()
76
+ if not config_graphfile.endswith(".html"):
77
+ config_graphfile = config_graphfile + ".html"
78
+ graph_html = os.path.join(site_dir, config_graphfile)
79
+ graph_max_html = os.path.join(site_dir, config_graphfile.replace(".html", "_max.html"))
80
+ graph_opts_file = os.path.join(os.path.dirname(__file__), "nodegraph\\graph_opts.json")
81
+ pyvis_opts_file = os.path.join(os.path.dirname(__file__), "nodegraph\\pyvis_opts.js")
82
+
83
+ if os.path.isfile(graph_max_html):
84
+ os.remove(graph_max_html)
85
+ generate_graph.build_graph(docs_dir, site_dir, graph_max_html, pyvis_opts_file, graph_opts_file, config_graphfile)
86
+
87
+ index_html = os.path.join(site_dir, 'index.html')
88
+ generate_graph.rebuild_graph_html(index_html, graph_max_html, graph_html)
89
+
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.1
2
+ Name: mkdocs-nodegraph
3
+ Version: 0.1.0
4
+ Summary: MkDocs plugin supports nodegraph
5
+ Home-page:
6
+ Author: JeongYong Hwang
7
+ Author-email: yonge123@gmail.com
8
+ License: MIT
9
+ Keywords: mkdocs,plugin,nodegraph
10
+ Requires-Dist: mkdocs >=1.4.0
11
+ Requires-Dist: mkdocs-material >=9.5.31
12
+ Requires-Dist: pyembed-markdown >=1.1.0
13
+ Requires-Dist: mkdocs-glightbox >=0.4.0
14
+ Requires-Dist: pyvis >=0.3.0
15
+ Requires-Dist: PyYAML >=6.0.2
16
+
@@ -0,0 +1,15 @@
1
+ mkdocs_nodegraph/__init__.py,sha256=zOp16BtF_poNEdUFUAXLGvRiop09zkmqDMnA4ND6WYM,78
2
+ mkdocs_nodegraph/plugin.py,sha256=1GSUjTg45n1sBF6ntS94gisbVeTDKn2FTJ0uodG1mlE,4126
3
+ mkdocs_nodegraph/nodegraph/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ mkdocs_nodegraph/nodegraph/generate_graph.py,sha256=qltJikRXfEoZ5vWXjJS3qT4-xPAGSTOsRpnUsvYBSDs,11931
5
+ mkdocs_nodegraph/nodegraph/graph_opts.json,sha256=3QJeAjLMIJPM__ed_HhIJImIkVqiA6rqjE71p0D10hg,127
6
+ mkdocs_nodegraph/nodegraph/mdfile.py,sha256=NUMp_O3AeVjDtQOT_T8O32hlnxenp5sbEbtr84MQLvk,477
7
+ mkdocs_nodegraph/nodegraph/mdparser.py,sha256=XUMQRlAgoxemhlbwStmhYMI4QZ1q6h9uryVXyzDfMpM,3188
8
+ mkdocs_nodegraph/nodegraph/pyvis_opts.js,sha256=3Ck8SuBq3ZHmlRKYZbCFX_4rD0deVP5KgDksd8bZroU,689
9
+ mkdocs_nodegraph/nodegraph/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ mkdocs_nodegraph/nodegraph/templates/template.html,sha256=NW2bqk9-XK6fulpCh0HLZyBReMkugQ-AfrK_sXZcN0M,50155
11
+ mkdocs_nodegraph-0.1.0.dist-info/METADATA,sha256=jfugX_cS4-WqXwBUtkkYte0neydhCjBwS9YkyJTdBwc,444
12
+ mkdocs_nodegraph-0.1.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
13
+ mkdocs_nodegraph-0.1.0.dist-info/entry_points.txt,sha256=Xz7JqUvREepsdgFWvHLFqQm4cz2-ehSDRg_S4AIkdSU,69
14
+ mkdocs_nodegraph-0.1.0.dist-info/top_level.txt,sha256=OKvqDlB02NP3wkGRWs3ydmlX8h9q-oPNNcx3aZ2SMvI,17
15
+ mkdocs_nodegraph-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [mkdocs.plugins]
2
+ nodegraph = mkdocs_nodegraph.plugin:GraphViewPlugin
@@ -0,0 +1 @@
1
+ mkdocs_nodegraph