Skip to content
This repository was archived by the owner on May 11, 2022. It is now read-only.

Commit fefd6a4

Browse files
authored
Replaced Markdown Code with SnakeMD Library (#41)
* Converting code to use SnakeMD * Reworked markdown for how_to * Removed local markdown file * Slowly working through library update * Slowly transitioning code * Updated generate program list * Reworked code! * Working through the wiki * Reworking code to use SnakeMD * Reworked code to use InlineText * Testing code * Fixed an issue with READMEs * Added errors * Upgraded version
1 parent ee6008b commit fefd6a4

5 files changed

Lines changed: 159 additions & 251 deletions

File tree

generate_docs/how_to.py

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Optional
2-
from bs4 import BeautifulSoup
3-
import requests
4-
import feedparser
52

6-
from generate_docs.markdown import MarkdownPage
3+
import feedparser
4+
import requests
5+
from bs4 import BeautifulSoup
6+
from snake.md import Document, Table, InlineText
77

88

99
def get_intro_text():
@@ -66,7 +66,7 @@ def get_test(title: str):
6666

6767
class HowTo:
6868
def __init__(self):
69-
self.page: Optional[MarkdownPage] = None
69+
self.page: Optional[Document] = None
7070
self.feed: Optional[list] = None
7171
self._load_data()
7272
self._build_readme()
@@ -75,48 +75,52 @@ def _load_data(self):
7575
self.feed = get_series_posts()
7676

7777
def _build_readme(self):
78-
self.page = MarkdownPage("README")
78+
self.page = Document("README")
7979

8080
# Introduction
81-
self.page.add_content("# How to Python - Source Code")
82-
self.page.add_section_break()
83-
self.page.add_content(get_intro_text())
84-
self.page.add_section_break()
85-
86-
# Article List
87-
self.page.add_table_header(
88-
"Index",
89-
"Title",
90-
"Publish Date",
91-
"Article",
92-
"Video",
93-
"Challenge",
81+
self.page.add_header("How to Python - Source Code")
82+
self.page.add_paragraph(get_intro_text())
83+
84+
# Table
85+
headers = [
86+
"Index",
87+
"Title",
88+
"Publish Date",
89+
"Article",
90+
"Video",
91+
"Challenge",
9492
"Notebook",
9593
"Testing"
94+
]
95+
table = Table(
96+
[InlineText(header) for header in headers],
97+
self.build_table()
9698
)
97-
self.build_table()
99+
self.page.add_element(table)
98100

99-
def build_table(self):
101+
def build_table(self) -> list[list[InlineText]]:
100102
index = 1
103+
body = []
101104
for entry in self.feed:
102105
if "Code Snippets" not in entry.title:
103-
article = f"[Article]({entry.link})"
106+
article = InlineText("Article", url=entry.link)
104107
youtube_url = get_youtube_video(entry)
105-
youtube = f"[Video]({youtube_url})" if youtube_url else ""
108+
youtube = InlineText("Video", url=youtube_url) if youtube_url else InlineText("")
106109
challenge_url = get_challenge(entry.title)
107-
challenge = f"[Challenge]({challenge_url})" if challenge_url else ""
110+
challenge = InlineText("Challenge", url=challenge_url) if challenge_url else InlineText("")
108111
notebook_url = get_notebook(entry.title)
109-
notebook = f"[Notebook]({notebook_url})" if notebook_url else ""
112+
notebook = InlineText("Notebook", url=notebook_url) if notebook_url else ""
110113
test_url = get_test(entry.title)
111-
test = f"[Test]({test_url})" if test_url else ""
112-
self.page.add_table_row(
113-
str(index),
114-
entry.title,
115-
entry.published,
116-
article,
117-
youtube,
118-
challenge,
114+
test = InlineText("Test", url=test_url) if test_url else ""
115+
body.append([
116+
InlineText(str(index)),
117+
InlineText(entry.title),
118+
InlineText(entry.published),
119+
article,
120+
youtube,
121+
challenge,
119122
notebook,
120123
test
121-
)
124+
])
122125
index += 1
126+
return body

generate_docs/markdown.py

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)