Skip to content

Commit

Permalink
Merge pull request #27 from harishmohanraj/polishing
Browse files Browse the repository at this point in the history
Polishing
  • Loading branch information
harishmohanraj authored Dec 19, 2024
2 parents 06b4d6c + 42d9691 commit 34fed4e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 58 deletions.
10 changes: 10 additions & 0 deletions website/mint-style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions website/process_api_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,6 @@ def write_file_content(file_path: str, content: str) -> None:
f.write(content)


def add_code_fences(content: str) -> str:
"""Add Python code fence markers to content starting with 'import'.
Args:
content: Content to process
Returns:
Content with Python code blocks properly fenced
"""
return content
lines = content.split("\n")
output = []
i = 0

while i < len(lines):
if lines[i].strip().startswith("import"):
block = []
# Collect lines until next markdown marker
while i < len(lines) and not lines[i].strip().startswith(("---", "#", "-", "`")):
block.append(lines[i])
i += 1
if block:
output.extend(["```python", *block, "```"])
else:
output.append(lines[i])
i += 1

return "\n".join(output)


def convert_md_to_mdx(input_dir: Path) -> None:
"""Convert all .md files in directory to .mdx while preserving structure.
Expand All @@ -118,9 +89,6 @@ def convert_md_to_mdx(input_dir: Path) -> None:
# Escape HTML tags
processed_content = escape_html_tags(content)

# Add code fences
processed_content = add_code_fences(processed_content)

# Update sidenav title
processed_content = processed_content.replace("sidebar_label: ", "sidebarTitle: ")

Expand Down
35 changes: 10 additions & 25 deletions website/process_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,45 +415,30 @@ def post_process_mdx(rendered_mdx: Path, source_notebooks: Path, front_matter: D
# content = f"# {front_matter['title']}\n{content}"
# inject in content directly after the markdown title the word done
# Find the end of the line with the title
title_end = content.find("\n", content.find("#"))
# title_end = content.find("\n", content.find("#"))

# Extract page title
title = content[content.find("#") + 1 : content.find("\n", content.find("#"))].strip()
# title = content[content.find("#") + 1 : content.find("\n", content.find("#"))].strip()
# If there is a { in the title we trim off the { and everything after it
if "{" in title:
title = title[: title.find("{")].strip()
# if "{" in title:
# title = title[: title.find("{")].strip()

github_link = f"https://github.com/ag2ai/ag2/blob/main/{repo_relative_notebook}"
content = (
content[:title_end]
+ f'\n<a href="{github_link}" target="_blank">'
f'\n<a href="{github_link}" class="github-badge" target="_blank">'
+ """<img noZoom src="https://img.shields.io/badge/Open%20on%20GitHub-grey?logo=github" alt="Open on GitHub" />"""
+ "</a>"
+ content[title_end:]
+ content
)
# content = (
# content[:title_end]
# + '<a href="https://img.shields.io/badge/Open%20on%20GitHub-grey?logo=github)]('
# + github_link
# + ")"
# + """ target="_blank" alt="Open on GitHub">
# <img noZoom src="/path/image.jpg"/>
# </a>"""
# + "\n[![Open on GitHub](https://img.shields.io/badge/Open%20on%20GitHub-grey?logo=github)]("
# + github_link
# + ")"
# + content[title_end:]
# )

# If no colab link is present, insert one
if "colab-badge.svg" not in content:
colab_link = f"https://colab.research.google.com/github/ag2ai/ag2/blob/main/{repo_relative_notebook}"
content = (
content[:title_end]
+ "\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]("
+ colab_link
+ ")"
+ content[title_end:]
f'\n<a href="{colab_link}" class="colab-badge" target="_blank">'
+ """<img noZoom src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab" />"""
+ "</a>"
+ content
)

# Create the front matter metadata js file for examples by notebook section
Expand Down
1 change: 0 additions & 1 deletion website/snippets/components/GalleryPage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export const GalleryPage = ({
<CardGroup cols={3}>
{galleryItems.map((item, index) => (
<Card key={index} href={item.link}>
{imageFunc(item)}
<h5 className="card-title">{item.title}</h5>
{badges(item)}
<p className="card-description">{item.description || item.title}</p>
Expand Down

0 comments on commit 34fed4e

Please sign in to comment.