Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions dev/build_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

from jinja2 import Environment, PackageLoader, select_autoescape

from pygraph.builders import DirectoryBuilder
from pygraph.builders import GitRepoBuilder
from pygraph.builders.styles import GitRepoStyle
from pygraph.pygraph import Network, Node
from pygraph.utils import to_html

ENV = Environment(loader=PackageLoader('pygraph'), autoescape=select_autoescape())

BUILT: list[GitRepoBuilder] = []

TARGETS = [
# Qiskit
'https://github.com/Qiskit/rustworkx.git',
Expand Down Expand Up @@ -44,22 +46,23 @@
]


def build_graph(url: str) -> DirectoryBuilder:
def build_graph(url: str) -> GitRepoBuilder:
template = ENV.get_template('html/base.html')
builder = DirectoryBuilder(
builder = GitRepoBuilder(
url,
silent=True,
style=GitRepoStyle,
ignores={'patterns': ['.git/']},
network_options={'nodes': {'font': {'face': 'JetBrains Mono'}}},
)
nx = builder.web_network()
nx = builder.network()
nx.spring_solve()
out = Path(f'docs/ref/repo-graphs/{builder.user}/{builder.repo}.html')
out = Path(f'docs/ref/repo-graphs/{builder.user}/{builder.name}.html')
out.parent.mkdir(parents=True, exist_ok=True)
html = to_html(
nx,
template,
network={'title': builder.repo},
network={'title': builder.name},
progressor={'enabled': True},
selectors={
'node': {
Expand All @@ -78,7 +81,6 @@ def build_graph(url: str) -> DirectoryBuilder:

def main():
template = ENV.get_template('html/base.html')
built: list[DirectoryBuilder] = []

with ThreadPoolExecutor(len(TARGETS), thread_name_prefix='pygraph-') as executor:
futs = {executor.submit(build_graph, targ): targ for targ in TARGETS}
Expand All @@ -88,8 +90,8 @@ def main():
except TimeoutError as e:
print(f'\n[FAILED]: {futs[future]} timed out ({e})')
continue
print(f'\nbuilt {builder.repo}')
built.append(builder)
print(f'built {builder.name}')
BUILT.append(builder)

nx = Network(
nodes={
Expand All @@ -102,8 +104,8 @@ def main():
},
)
nx.barnes_hut(gravitationalConstant=-6000, avoidOverlap=0.75)
for builder in built:
repo = builder.repo
for builder in BUILT:
repo = builder.name
user = str(builder.user)
if f'user:{user}' not in nx:
usr_clr = f'#{md5(user.encode('utf-8'), usedforsecurity=False).hexdigest()[:6]}'
Expand Down Expand Up @@ -131,7 +133,7 @@ def main():
)
nx.add_node(repo_node)
nx.add_edge((f'user:{user}', f'repo:{repo}'))
builder.delete_directory()
builder.delete_temp_directory()
print(f'cleaned up {repo}')

nx.spring_solve()
Expand All @@ -149,9 +151,16 @@ def main():
},
},
)
print('\nwriting index...')
print('writing index...')
out.write_text(html)


if __name__ == '__main__':
main()
try:
main()
except Exception:
print('[FAILED]: Cleaning...')
for builder in BUILT:
builder.delete_temp_directory()
print(f'Deleted {builder.name}')
raise
4 changes: 2 additions & 2 deletions docs/ref/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@
let openLink = (item) => (item?.link) && window.open(item?.link) || false
let resolveLink = (event) => getNodes(event.nodes[0]) || getEdges(event.edges[0]) || undefined
const data = {
nodes: new vis.DataSet([{"color": "#7C7C7CAB", "id": "user:hwelch-fle", "image": "https://github.com/hwelch-fle.png?size=100", "label": "hwelch-fle", "link": "https://github.com/hwelch-fle", "shadow": {"color": "#e863dc", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "hwelch-fle", "x": -428, "y": 293}, {"group": "hwelch-fle", "id": "repo:geo-grab", "label": "geo-grab", "link": "repo-graphs/hwelch-fle/geo-grab.html", "title": "geo-grab", "x": -413, "y": 241}, {"group": "hwelch-fle", "id": "repo:cimple", "label": "cimple", "link": "repo-graphs/hwelch-fle/cimple.html", "title": "cimple", "x": -395, "y": 339}, {"group": "hwelch-fle", "id": "repo:arcpie", "label": "arcpie", "link": "repo-graphs/hwelch-fle/arcpie.html", "title": "arcpie", "x": -370, "y": 287}, {"color": "#7C7C7CAB", "id": "user:ionelmc", "image": "https://github.com/ionelmc.png?size=100", "label": "ionelmc", "link": "https://github.com/ionelmc", "shadow": {"color": "#da76f1", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "ionelmc", "x": 384, "y": -368}, {"group": "ionelmc", "id": "repo:pytest-benchmark", "label": "pytest-benchmark", "link": "repo-graphs/ionelmc/pytest-benchmark.html", "title": "pytest-benchmark", "x": 400, "y": -334}, {"group": "hwelch-fle", "id": "repo:pygraph", "label": "pygraph", "link": "repo-graphs/hwelch-fle/pygraph.html", "title": "pygraph", "x": -469, "y": 263}, {"color": "#7C7C7CAB", "id": "user:pallets", "image": "https://github.com/pallets.png?size=100", "label": "pallets", "link": "https://github.com/pallets", "shadow": {"color": "#63f212", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "pallets", "x": -99, "y": 79}, {"group": "pallets", "id": "repo:jinja", "label": "jinja", "link": "repo-graphs/pallets/jinja.html", "title": "jinja", "x": -150, "y": 84}, {"color": "#7C7C7CAB", "id": "user:encode", "image": "https://github.com/encode.png?size=100", "label": "encode", "link": "https://github.com/encode", "shadow": {"color": "#97a576", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "encode", "x": -407, "y": -630}, {"group": "encode", "id": "repo:httpx", "label": "httpx", "link": "repo-graphs/encode/httpx.html", "title": "httpx", "x": -453, "y": -657}, {"group": "hwelch-fle", "id": "repo:plankapy", "label": "plankapy", "link": "repo-graphs/hwelch-fle/plankapy.html", "title": "plankapy", "x": -472, "y": 334}, {"group": "pallets", "id": "repo:click", "label": "click", "link": "repo-graphs/pallets/click.html", "title": "click", "x": -61, "y": 71}, {"color": "#7C7C7CAB", "id": "user:visjs", "image": "https://github.com/visjs.png?size=100", "label": "visjs", "link": "https://github.com/visjs", "shadow": {"color": "#fd961a", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "visjs", "x": -212, "y": -429}, {"group": "visjs", "id": "repo:vis-network", "label": "vis-network", "link": "repo-graphs/visjs/vis-network.html", "title": "vis-network", "x": -175, "y": -419}, {"color": "#7C7C7CAB", "id": "user:Qiskit", "image": "https://github.com/Qiskit.png?size=100", "label": "Qiskit", "link": "https://github.com/Qiskit", "shadow": {"color": "#37100a", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "Qiskit", "x": 192, "y": 840}, {"group": "Qiskit", "id": "repo:rustworkx", "label": "rustworkx", "link": "repo-graphs/Qiskit/rustworkx.html", "title": "rustworkx", "x": 174, "y": 807}, {"color": "#7C7C7CAB", "id": "user:pytest-dev", "image": "https://github.com/pytest-dev.png?size=100", "label": "pytest-dev", "link": "https://github.com/pytest-dev", "shadow": {"color": "#b0f8da", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "pytest-dev", "x": 48, "y": -998}, {"group": "pytest-dev", "id": "repo:pytest", "label": "pytest", "link": "repo-graphs/pytest-dev/pytest.html", "title": "pytest", "x": 63, "y": -963}, {"color": "#7C7C7CAB", "id": "user:fastapi", "image": "https://github.com/fastapi.png?size=100", "label": "fastapi", "link": "https://github.com/fastapi", "shadow": {"color": "#0d32bc", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "fastapi", "x": 944, "y": 385}, {"group": "fastapi", "id": "repo:typer", "label": "typer", "link": "repo-graphs/fastapi/typer.html", "title": "typer", "x": 999, "y": 396}, {"group": "fastapi", "id": "repo:fastapi", "label": "fastapi", "link": "repo-graphs/fastapi/fastapi.html", "title": "fastapi", "x": 900, "y": 377}]),
edges: new vis.DataSet([{"from": "user:hwelch-fle", "to": "repo:geo-grab"}, {"from": "user:hwelch-fle", "to": "repo:cimple"}, {"from": "user:hwelch-fle", "to": "repo:arcpie"}, {"from": "user:ionelmc", "to": "repo:pytest-benchmark"}, {"from": "user:hwelch-fle", "to": "repo:pygraph"}, {"from": "user:pallets", "to": "repo:jinja"}, {"from": "user:encode", "to": "repo:httpx"}, {"from": "user:hwelch-fle", "to": "repo:plankapy"}, {"from": "user:pallets", "to": "repo:click"}, {"from": "user:visjs", "to": "repo:vis-network"}, {"from": "user:Qiskit", "to": "repo:rustworkx"}, {"from": "user:pytest-dev", "to": "repo:pytest"}, {"from": "user:fastapi", "to": "repo:typer"}, {"from": "user:fastapi", "to": "repo:fastapi"}]),
nodes: new vis.DataSet([{"color": "#7C7C7CAB", "id": "user:hwelch-fle", "image": "https://github.com/hwelch-fle.png?size=100", "label": "hwelch-fle", "link": "https://github.com/hwelch-fle", "shadow": {"color": "#e863dc", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "hwelch-fle", "x": 670, "y": 175}, {"group": "hwelch-fle", "id": "repo:arcpie", "label": "arcpie", "link": "repo-graphs/hwelch-fle/arcpie.html", "title": "arcpie", "x": 748, "y": 193}, {"color": "#7C7C7CAB", "id": "user:ionelmc", "image": "https://github.com/ionelmc.png?size=100", "label": "ionelmc", "link": "https://github.com/ionelmc", "shadow": {"color": "#da76f1", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "ionelmc", "x": 377, "y": 527}, {"group": "ionelmc", "id": "repo:pytest-benchmark", "label": "pytest-benchmark", "link": "repo-graphs/ionelmc/pytest-benchmark.html", "title": "pytest-benchmark", "x": 440, "y": 551}, {"group": "hwelch-fle", "id": "repo:geo-grab", "label": "geo-grab", "link": "repo-graphs/hwelch-fle/geo-grab.html", "title": "geo-grab", "x": 613, "y": 128}, {"group": "hwelch-fle", "id": "repo:cimple", "label": "cimple", "link": "repo-graphs/hwelch-fle/cimple.html", "title": "cimple", "x": 708, "y": 103}, {"group": "hwelch-fle", "id": "repo:pygraph", "label": "pygraph", "link": "repo-graphs/hwelch-fle/pygraph.html", "title": "pygraph", "x": 609, "y": 205}, {"color": "#7C7C7CAB", "id": "user:encode", "image": "https://github.com/encode.png?size=100", "label": "encode", "link": "https://github.com/encode", "shadow": {"color": "#97a576", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "encode", "x": 786, "y": -858}, {"group": "encode", "id": "repo:httpx", "label": "httpx", "link": "repo-graphs/encode/httpx.html", "title": "httpx", "x": 789, "y": -807}, {"color": "#7C7C7CAB", "id": "user:pallets", "image": "https://github.com/pallets.png?size=100", "label": "pallets", "link": "https://github.com/pallets", "shadow": {"color": "#63f212", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "pallets", "x": -586, "y": -290}, {"group": "pallets", "id": "repo:click", "label": "click", "link": "repo-graphs/pallets/click.html", "title": "click", "x": -552, "y": -355}, {"group": "hwelch-fle", "id": "repo:plankapy", "label": "plankapy", "link": "repo-graphs/hwelch-fle/plankapy.html", "title": "plankapy", "x": 685, "y": 248}, {"group": "pallets", "id": "repo:jinja", "label": "jinja", "link": "repo-graphs/pallets/jinja.html", "title": "jinja", "x": -606, "y": -241}, {"color": "#7C7C7CAB", "id": "user:visjs", "image": "https://github.com/visjs.png?size=100", "label": "visjs", "link": "https://github.com/visjs", "shadow": {"color": "#fd961a", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "visjs", "x": -172, "y": -858}, {"group": "visjs", "id": "repo:vis-network", "label": "vis-network", "link": "repo-graphs/visjs/vis-network.html", "title": "vis-network", "x": -165, "y": -907}, {"color": "#7C7C7CAB", "id": "user:Qiskit", "image": "https://github.com/Qiskit.png?size=100", "label": "Qiskit", "link": "https://github.com/Qiskit", "shadow": {"color": "#37100a", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "Qiskit", "x": -964, "y": -562}, {"group": "Qiskit", "id": "repo:rustworkx", "label": "rustworkx", "link": "repo-graphs/Qiskit/rustworkx.html", "title": "rustworkx", "x": -912, "y": -577}, {"color": "#7C7C7CAB", "id": "user:pytest-dev", "image": "https://github.com/pytest-dev.png?size=100", "label": "pytest-dev", "link": "https://github.com/pytest-dev", "shadow": {"color": "#b0f8da", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "pytest-dev", "x": -951, "y": 319}, {"group": "pytest-dev", "id": "repo:pytest", "label": "pytest", "link": "repo-graphs/pytest-dev/pytest.html", "title": "pytest", "x": -999, "y": 362}, {"color": "#7C7C7CAB", "id": "user:fastapi", "image": "https://github.com/fastapi.png?size=100", "label": "fastapi", "link": "https://github.com/fastapi", "shadow": {"color": "#0d32bc", "enabled": true, "size": 5, "x": 3, "y": 3}, "shape": "circularImage", "shapeProperties": {"borderRadius": 10, "useBorderWithImage": true}, "title": "fastapi", "x": -176, "y": 874}, {"group": "fastapi", "id": "repo:typer", "label": "typer", "link": "repo-graphs/fastapi/typer.html", "title": "typer", "x": -231, "y": 873}, {"group": "fastapi", "id": "repo:fastapi", "label": "fastapi", "link": "repo-graphs/fastapi/fastapi.html", "title": "fastapi", "x": -112, "y": 892}]),
edges: new vis.DataSet([{"from": "user:hwelch-fle", "to": "repo:arcpie"}, {"from": "user:ionelmc", "to": "repo:pytest-benchmark"}, {"from": "user:hwelch-fle", "to": "repo:geo-grab"}, {"from": "user:hwelch-fle", "to": "repo:cimple"}, {"from": "user:hwelch-fle", "to": "repo:pygraph"}, {"from": "user:encode", "to": "repo:httpx"}, {"from": "user:pallets", "to": "repo:click"}, {"from": "user:hwelch-fle", "to": "repo:plankapy"}, {"from": "user:pallets", "to": "repo:jinja"}, {"from": "user:visjs", "to": "repo:vis-network"}, {"from": "user:Qiskit", "to": "repo:rustworkx"}, {"from": "user:pytest-dev", "to": "repo:pytest"}, {"from": "user:fastapi", "to": "repo:typer"}, {"from": "user:fastapi", "to": "repo:fastapi"}]),
}
const options = {
"autoResize": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/repo-graphs/Qiskit/rustworkx.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ref/repo-graphs/encode/httpx.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ref/repo-graphs/fastapi/fastapi.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ref/repo-graphs/fastapi/typer.html

Large diffs are not rendered by default.

Loading