Skip to content

Commit 3db9b80

Browse files
upgraded styling on docs
1 parent 40fcf62 commit 3db9b80

File tree

11 files changed

+92
-38
lines changed

11 files changed

+92
-38
lines changed

codegen-git/src/codegen_git/utils/clone_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def url_to_github(url: str, branch: str) -> str:
99
clone_url = url.removesuffix(".git").replace("[email protected]:", "github.com/")
10-
return f"https://{clone_url}/blob/{branch}"
10+
return f"{clone_url}/blob/{branch}"
1111

1212

1313
def get_clone_url_for_repo_config(repo_config: RepoConfig, github_type: GithubType = GithubType.GithubEnterprise) -> str:

docs/mint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"colors": {
1313
"primary": "#a277ff",
1414
"light": "#a277ff",
15-
"dark": "#a277ff",
15+
"dark": "#575453",
1616
"anchors": {
1717
"from": "#61ffca",
1818
"to": "#61ffca"

docs/snippets/Attribute.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const Attribute = ({ type, description }) => (
2+
<div className="py-6 first:pt-3 dark:border-gray-300/[0.06] text-sm font-normal">
3+
<div className="inline-grid grid-cols-[auto_auto] gap-1 font-mono py-2">
4+
{type}
5+
</div>
6+
<p className="mt-2">{description}</p>
7+
</div>
8+
)

docs/snippets/GithubLinkNote.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const GithubLinkNote = ({link}) => (
2+
<Info>
3+
<div className="flex gap-5 items-center">View Source on <a target="_blank" rel="noopener noreferrer" href={link}> Github</a></div>
4+
</Info>
5+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const HorizontalDivider = ({light=false}) => (
2+
<div className="divide-y">
3+
<div className={`divide-y ${light ? "dark:border-gray-300/[0.06]" : "border-gray-600"}`}></div>
4+
<div className={`divide-y ${light ? "dark:border-gray-300/[0.06]" : "border-gray-600"}`}></div>
5+
</div>
6+
)

docs/snippets/Parameter.mdx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
export const Parameter = ({name, type, required, description, defaultValue}) => (
2-
<div className="py-6 first:pt-3 border-gray-600 text-sm font-normal">
3-
<div className="flex gap-4 items-center">
4-
<code className="text-sm bg-gray-100 px-2 py-0.5 rounded">{name}</code>
1+
export const Parameter = ({name, type, description, defaultValue}) => (
2+
<div className="py-6 first:pt-3 dark:border-gray-300/[0.06] text-sm font-normal">
3+
<div className="flex justify-between items-start font-mono">
4+
<div className="flex gap-4 items-start">
5+
<div className="flex gap-1 items-center text-sm text-primary mt-2">
6+
{name}
7+
</div>
8+
<div className="inline-grid grid-cols-[auto_auto] gap-1 py-2">
9+
{type}
10+
</div>
11+
</div>
512

6-
{type}
7-
8-
9-
{required && <span className="text-sm border border-purple-500 px-2 py-0.5 rounded">required</span>}
10-
{ defaultValue && <div className="flex gap-4 items-center text-sm border border-purple-500 px-2 py-0.5 rounded">
11-
<span className="text-gray-500">Default:</span>
12-
<span className="text-purple-500">{defaultValue}</span>
13-
</div>}
13+
<div className="flex-shrink-0 mt-2">
14+
{defaultValue ? (
15+
<div className="flex gap-1 items-center text-sm border border-purple-500 px-2 py-0.5 rounded">
16+
<span className="text-gray-500">default:</span>
17+
<span className="text-purple-500">{defaultValue}</span>
18+
</div>
19+
) : (
20+
<span className="text-sm border border-purple-500 px-2 py-0.5 rounded">
21+
required
22+
</span>
23+
)}
24+
</div>
1425
</div>
15-
<p className="mt-2 text-white">{description}</p>
26+
<p className="mt-2">{description}</p>
1627
</div>
1728
)

docs/snippets/ParameterWrapper.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const ParameterWrapper = ({ children }) => (
22
<div className="pl-6 divide-y">
33
<h4 className="font-bold">Parameters</h4>
4-
<div className="divide-y border-gray-600">
4+
<div className="divide-y dark:border-gray-300/[0.06]">
55
{children}
66
</div>
77
</div>

docs/snippets/Return.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export const Return = ({return_type, description}) => (
22
<div className="pl-6 divide-y">
33
<h4 className="font-bold">Returns</h4>
4-
<div className="border-gray-600 ">
4+
<div className="dark:border-gray-300/[0.06] ">
55
<div className="py-6 first:pt-3 text-sm font-normal">
66
<div className="flex gap-4 items-center">
7-
<div className="relative">
7+
<div className="inline-grid grid-cols-[auto_auto] gap-1 font-mono py-2">
88
{return_type}
99
</div>
1010
</div>
11-
<p className="mt-2 text-white">{description}</p>
11+
<p className="mt-2">{description}</p>
1212
</div>
1313
</div>
1414
</div>

src/graph_sitter/code_generation/doc_utils/generate_docs_json.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from graph_sitter.core.class_definition import Class
1010
from graph_sitter.core.codebase import Codebase
1111

12-
ATTRIBUTES_TO_IGNORE = ["G", "node_id"]
12+
ATTRIBUTES_TO_IGNORE = ["G", "node_id", "angular"]
1313

1414

1515
def generate_docs_json(codebase: Codebase, head_commit: str) -> dict[str, dict[str, Any]]:
@@ -25,12 +25,21 @@ def generate_docs_json(codebase: Codebase, head_commit: str) -> dict[str, dict[s
2525
types_cache = {}
2626
attr_cache = {}
2727

28-
def update_class_doc(cls):
28+
def process_class_doc(cls):
2929
"""Update or create documentation for a class."""
3030
description = cls.docstring.source.strip('"""') if cls.docstring else None
3131
parent_classes = [f"<{create_path(parent)}>" for parent in cls.superclasses if isinstance(parent, Class) and has_documentation(parent)]
3232

33-
cls_doc = ClassDoc(title=cls.name, description=description, content=" ", path=create_path(cls), inherits_from=parent_classes, language=get_langauge(cls), version=str(head_commit))
33+
cls_doc = ClassDoc(
34+
title=cls.name,
35+
description=description,
36+
content=" ",
37+
path=create_path(cls),
38+
inherits_from=parent_classes,
39+
language=get_langauge(cls),
40+
version=str(head_commit),
41+
github_url=cls.github_url,
42+
)
3443

3544
return cls_doc
3645

@@ -47,7 +56,6 @@ def process_method(method, cls, cls_doc, seen_methods):
4756
return
4857

4958
method_path = create_path(method, cls)
50-
original_method_path = create_path(method)
5159
parameters = []
5260

5361
parsed = parse_docstring(method.docstring.source)
@@ -88,6 +96,7 @@ def process_method(method, cls, cls_doc, seen_methods):
8896
raises=parsed["raises"],
8997
metainfo=meta_data,
9098
version=str(head_commit),
99+
github_url=method.github_url,
91100
)
92101

93102
def process_attribute(attr, cls, cls_doc, seen_methods):
@@ -122,14 +131,15 @@ def process_attribute(attr, cls, cls_doc, seen_methods):
122131
raises=[],
123132
metainfo=meta_data,
124133
version=str(head_commit),
134+
github_url=attr.github_url,
125135
)
126136

127137
# Process all documented classes
128138
documented_classes = [cls for cls in codebase.classes if has_documentation(cls)]
129139

130140
for cls in tqdm(documented_classes):
131141
try:
132-
cls_doc = update_class_doc(cls)
142+
cls_doc = process_class_doc(cls)
133143
graph_sitter_docs.classes.append(cls_doc)
134144
seen_methods = set()
135145

src/graph_sitter/code_generation/doc_utils/schemas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class MethodDoc(BaseModel):
2222
raises: list[dict] | None = Field(..., description="The raises of the method")
2323
metainfo: dict = Field(..., description="Information about the method's true parent class and path")
2424
version: str = Field(..., description="The commit hash of the git commit that generated the docs")
25+
github_url: str = Field(..., description="The github url of the method")
2526

2627

2728
class ClassDoc(BaseModel):
@@ -34,6 +35,7 @@ class ClassDoc(BaseModel):
3435
version: str = Field(..., description="The commit hash of the git commit that generated the docs")
3536
methods: list[MethodDoc] = Field(default=[], description="The methods of the class")
3637
attributes: list[MethodDoc] = Field(default=[], description="The attributes of the class")
38+
github_url: str = Field(..., description="The github url of the class")
3739

3840

3941
class GSDocs(BaseModel):

0 commit comments

Comments
 (0)