mkdocs-nodegraph 0.4.0__tar.gz → 0.5.0__tar.gz

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.
Files changed (20) hide show
  1. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/PKG-INFO +28 -4
  2. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/README.md +15 -2
  3. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/__init__.py +1 -1
  4. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/nodegraph/generate_graph.py +43 -5
  5. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/nodegraph/graph_opts.json +2 -2
  6. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/nodegraph/mdparser.py +26 -9
  7. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/nodegraph/templates/template.html +546 -212
  8. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/plugin.py +1 -0
  9. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph.egg-info/PKG-INFO +28 -4
  10. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/setup.py +1 -1
  11. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/nodegraph/__init__.py +0 -0
  12. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/nodegraph/mdfile.py +0 -0
  13. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/nodegraph/pyvis_opts.js +0 -0
  14. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph/nodegraph/templates/__init__.py +0 -0
  15. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph.egg-info/SOURCES.txt +0 -0
  16. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph.egg-info/dependency_links.txt +0 -0
  17. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph.egg-info/entry_points.txt +0 -0
  18. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph.egg-info/requires.txt +0 -0
  19. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/mkdocs_nodegraph.egg-info/top_level.txt +0 -0
  20. {mkdocs_nodegraph-0.4.0 → mkdocs_nodegraph-0.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: mkdocs-nodegraph
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Node Graph plugin for Mkdocs Material
5
5
  Home-page: https://yonge123.github.io/mkdocs-nodegraph/nodegraph.html
6
6
  Author: JeongYong Hwang
@@ -18,6 +18,17 @@ Requires-Dist: pyembed-markdown>=1.1.0
18
18
  Requires-Dist: mkdocs-glightbox>=0.4.0
19
19
  Requires-Dist: pyvis>=0.3.0
20
20
  Requires-Dist: PyYAML>=6.0.2
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: keywords
27
+ Dynamic: license
28
+ Dynamic: project-url
29
+ Dynamic: requires-dist
30
+ Dynamic: requires-python
31
+ Dynamic: summary
21
32
 
22
33
  # mkdocs-nodegraph
23
34
 
@@ -35,11 +46,11 @@ It allows you to create interactive visualizations of your documentation structu
35
46
 
36
47
  <p align="center">
37
48
  <a>
38
- <img alt="example_image_001.png" src="https://github.com/yonge123/mkdocs-nodegraph/blob/master/sources/example_image_001.png?raw=true" data-hpc="true" class="Box-sc-g0xbh4-0 fzFXnm">
49
+ <img alt="example_image_002.png" src="https://github.com/yonge123/mkdocs-nodegraph/blob/master/sources/example_image_002.png?raw=true" data-hpc="true" class="Box-sc-g0xbh4-0 fzFXnm">
39
50
  </a>
40
51
 
41
52
 
42
- <!-- ![Example Network Graph Visualization](./sources/example_image_001.png) -->
53
+ <!-- ![Example Network Graph Visualization](./sources/example_image_002.png) -->
43
54
 
44
55
 
45
56
  <br>
@@ -106,6 +117,19 @@ mdfile_site -> A website URL that opens on click while holding the Alt key
106
117
 
107
118
  <br>
108
119
 
120
+ ## Click Node
121
+
122
+ `LMB` -> Open Node Page
123
+
124
+ `Ctrl + LMB` -> Open Node Page in a New Tab
125
+
126
+ `Alt + LMB` -> Open the mdfile_site Page from the metadata
127
+
128
+
129
+ <br>
130
+
131
+
132
+
109
133
  ## mkdocs.yml Configuration
110
134
 
111
135
 
@@ -14,11 +14,11 @@ It allows you to create interactive visualizations of your documentation structu
14
14
 
15
15
  <p align="center">
16
16
  <a>
17
- <img alt="example_image_001.png" src="https://github.com/yonge123/mkdocs-nodegraph/blob/master/sources/example_image_001.png?raw=true" data-hpc="true" class="Box-sc-g0xbh4-0 fzFXnm">
17
+ <img alt="example_image_002.png" src="https://github.com/yonge123/mkdocs-nodegraph/blob/master/sources/example_image_002.png?raw=true" data-hpc="true" class="Box-sc-g0xbh4-0 fzFXnm">
18
18
  </a>
19
19
 
20
20
 
21
- <!-- ![Example Network Graph Visualization](./sources/example_image_001.png) -->
21
+ <!-- ![Example Network Graph Visualization](./sources/example_image_002.png) -->
22
22
 
23
23
 
24
24
  <br>
@@ -85,6 +85,19 @@ mdfile_site -> A website URL that opens on click while holding the Alt key
85
85
 
86
86
  <br>
87
87
 
88
+ ## Click Node
89
+
90
+ `LMB` -> Open Node Page
91
+
92
+ `Ctrl + LMB` -> Open Node Page in a New Tab
93
+
94
+ `Alt + LMB` -> Open the mdfile_site Page from the metadata
95
+
96
+
97
+ <br>
98
+
99
+
100
+
88
101
  ## mkdocs.yml Configuration
89
102
 
90
103
 
@@ -1,3 +1,3 @@
1
1
  from mkdocs_nodegraph.plugin import GraphViewPlugin
2
2
 
3
- __version__ = "0.4.0"
3
+ __version__ = "0.4.1"
@@ -131,7 +131,7 @@ class GraphBuilder():
131
131
 
132
132
  # self.net.show_buttons(filter_=['physics', 'nodes', 'links'])
133
133
  # build graph from parsed markdown pages
134
- def build(self, mdfiles):
134
+ def build(self, mdfiles, tags=None):
135
135
  nx_graph = nx.Graph()
136
136
  edget_info_dic = dict()
137
137
  color_list = copy.deepcopy(beautifulcolors)
@@ -195,6 +195,7 @@ class GraphBuilder():
195
195
  label=mdfile.title,
196
196
  url=html,
197
197
  url2=alt_click_url,
198
+ nodetype="filenode",
198
199
  size=size,
199
200
  shape=shape,
200
201
  image=icon,
@@ -212,6 +213,40 @@ class GraphBuilder():
212
213
  edge_len = max_link * 45 + ( idx * 35)
213
214
  nx_graph.add_edge(mdfile.uid, link_uid, length=edge_len)
214
215
 
216
+ if tags:
217
+ for idx, tag in enumerate(tags):
218
+ tag_name = tag["name"]
219
+ tag_uid = tag["uid"]
220
+ link_uids = tag["link_uids"]
221
+ count_links = len(link_uids)
222
+ icon = ""
223
+ shape="dot"
224
+ alt_click_url = ""
225
+ tag_color = "#FFD415"
226
+ size = 50 + (count_links * 4)
227
+ if size > 120:
228
+ size = 120
229
+ nx_graph.add_node(tag_uid,
230
+ label=tag_name,
231
+ url="",
232
+ url2=alt_click_url,
233
+ nodetype="tagnode",
234
+ size=size,
235
+ shape=shape,
236
+ image=icon,
237
+ color=tag_color,
238
+ opacity=1,
239
+ borderWidth=2,
240
+ )
241
+
242
+ edge_len = count_links * 45 + ( idx * 35)
243
+ if link_uids:
244
+ for link_uid in link_uids:
245
+ nx_graph.add_edge(tag_uid,
246
+ link_uid,
247
+ length=edge_len
248
+ )
249
+
215
250
  # self.net.from_nx(nx_graph)
216
251
  self.net.from_nx(nx_graph,
217
252
  default_node_size=50,
@@ -247,7 +282,8 @@ def load_pyvis_opts(file_path):
247
282
  return fout.read()
248
283
 
249
284
 
250
- def build_graph(docs_dir, site_dir, output_file, pyvis_opts_file, graph_opts_file, config_graphfile):
285
+ def build_graph(docs_dir, site_dir, output_file, pyvis_opts_file,
286
+ graph_opts_file, config_graphfile):
251
287
  if not os.path.isfile(pyvis_opts_file):
252
288
  raise IOError(f'Failed to find file -> "{pyvis_opts_file}"')
253
289
 
@@ -258,14 +294,16 @@ def build_graph(docs_dir, site_dir, output_file, pyvis_opts_file, graph_opts_fil
258
294
  os.makedirs(outputDir, exist_ok=True)
259
295
 
260
296
  parser = MdParser(docs_dir)
261
- mdfiles = parser.parse()
262
-
297
+ parser.parse()
298
+ mdfiles = parser.mdfiles
299
+ tags = parser.tags
300
+
263
301
  graph_config = read_config(graph_opts_file)
264
302
  graph_opts = load_graph_opts(graph_config)
265
303
  pyvis_opts = load_pyvis_opts(pyvis_opts_file)
266
304
 
267
305
  builder = GraphBuilder(pyvis_opts, graph_opts, output_file, config_graphfile, docs_dir, site_dir)
268
- builder.build(mdfiles)
306
+ builder.build(mdfiles, tags)
269
307
 
270
308
 
271
309
  def rebuild_graph_html(index_path, graph_path, output_path=None):
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "width": "100%",
3
- "height": "1400px",
3
+ "height": "90vh",
4
4
  "heading": "",
5
- "bgcolor": "#222222",
5
+ "bgcolor": "191B20",
6
6
  "font_color": "#94A3B8"
7
7
  }
@@ -52,6 +52,7 @@ class MdParser():
52
52
 
53
53
  def __init__(self, target_dir):
54
54
  self.mdfiles = []
55
+ self.tags = []
55
56
  self.target_dir = target_dir
56
57
 
57
58
  def parse_md(self, file_name):
@@ -61,8 +62,9 @@ class MdParser():
61
62
  title = ""
62
63
  metadata = ""
63
64
  return MdFile(file_name, base_name, title, links, link_uids, metadata)
64
-
65
+
65
66
  def parse(self):
67
+ tags_dic = dict()
66
68
  uid = 1
67
69
  for subdir, dirs, files in os.walk(self.target_dir):
68
70
  for f in files:
@@ -71,14 +73,20 @@ class MdParser():
71
73
 
72
74
  if not any(x for x in self.mdfiles if x.file_path == path):
73
75
  md = self.parse_md(path)
76
+ md.uid = uid
77
+ self.mdfiles.append(md)
78
+
74
79
  parseMedata = getMetadata(path)
75
80
  if parseMedata:
76
81
  metadata = yaml.safe_load(parseMedata)
77
82
  md.metadata = metadata
78
83
 
79
- md.uid = uid
84
+ if "tags" in metadata:
85
+ for tag in metadata["tags"]:
86
+ if tag not in tags_dic:
87
+ tags_dic[tag] = set()
88
+ tags_dic[tag].add(uid)
80
89
  uid += 1
81
- self.mdfiles.append(md)
82
90
 
83
91
  for mdfile in self.mdfiles:
84
92
  uids = set()
@@ -86,10 +94,19 @@ class MdParser():
86
94
  for link in mdfile.mdlinks:
87
95
  link_basename = os.path.basename(link)
88
96
  link_new = link.replace("../", "/").replace("./", "").replace("/", "").replace(".", "")
89
- uid = list(filter(lambda x: (x.file_path.replace("\\", "").replace("../", "/").replace("./", "").replace("/", "").replace(".", "").endswith(link_new) and os.path.basename(x.file_path) == link_basename), self.mdfiles))
90
- if len(uid) > 0:
91
- uids.add(uid[0].uid)
92
-
97
+ getmdfiles = list(filter(lambda x: (x.file_path.replace("\\", "").replace("../", "/").replace("./", "").replace("/", "").replace(".", "").endswith(link_new) and os.path.basename(x.file_path) == link_basename), self.mdfiles))
98
+ if len(getmdfiles) > 0:
99
+ uids.add(getmdfiles[0].uid)
100
+
93
101
  mdfile.link_uids = list(uids)
94
-
95
- return self.mdfiles
102
+
103
+ if tags_dic:
104
+ for tag, link_uids in tags_dic.items():
105
+ self.tags.append({
106
+ 'name': tag,
107
+ 'uid': uid,
108
+ 'link_uids': link_uids
109
+ })
110
+ uid += 1
111
+
112
+ return self.mdfiles, self.tags