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

Commit

Permalink
Replaced Markdown Code with SnakeMD Library (#41)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jrg94 authored Jul 19, 2021
1 parent ee6008b commit fefd6a4
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 251 deletions.
72 changes: 38 additions & 34 deletions generate_docs/how_to.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Optional
from bs4 import BeautifulSoup
import requests
import feedparser

from generate_docs.markdown import MarkdownPage
import feedparser
import requests
from bs4 import BeautifulSoup
from snake.md import Document, Table, InlineText


def get_intro_text():
Expand Down Expand Up @@ -66,7 +66,7 @@ def get_test(title: str):

class HowTo:
def __init__(self):
self.page: Optional[MarkdownPage] = None
self.page: Optional[Document] = None
self.feed: Optional[list] = None
self._load_data()
self._build_readme()
Expand All @@ -75,48 +75,52 @@ def _load_data(self):
self.feed = get_series_posts()

def _build_readme(self):
self.page = MarkdownPage("README")
self.page = Document("README")

# Introduction
self.page.add_content("# How to Python - Source Code")
self.page.add_section_break()
self.page.add_content(get_intro_text())
self.page.add_section_break()

# Article List
self.page.add_table_header(
"Index",
"Title",
"Publish Date",
"Article",
"Video",
"Challenge",
self.page.add_header("How to Python - Source Code")
self.page.add_paragraph(get_intro_text())

# Table
headers = [
"Index",
"Title",
"Publish Date",
"Article",
"Video",
"Challenge",
"Notebook",
"Testing"
]
table = Table(
[InlineText(header) for header in headers],
self.build_table()
)
self.build_table()
self.page.add_element(table)

def build_table(self):
def build_table(self) -> list[list[InlineText]]:
index = 1
body = []
for entry in self.feed:
if "Code Snippets" not in entry.title:
article = f"[Article]({entry.link})"
article = InlineText("Article", url=entry.link)
youtube_url = get_youtube_video(entry)
youtube = f"[Video]({youtube_url})" if youtube_url else ""
youtube = InlineText("Video", url=youtube_url) if youtube_url else InlineText("")
challenge_url = get_challenge(entry.title)
challenge = f"[Challenge]({challenge_url})" if challenge_url else ""
challenge = InlineText("Challenge", url=challenge_url) if challenge_url else InlineText("")
notebook_url = get_notebook(entry.title)
notebook = f"[Notebook]({notebook_url})" if notebook_url else ""
notebook = InlineText("Notebook", url=notebook_url) if notebook_url else ""
test_url = get_test(entry.title)
test = f"[Test]({test_url})" if test_url else ""
self.page.add_table_row(
str(index),
entry.title,
entry.published,
article,
youtube,
challenge,
test = InlineText("Test", url=test_url) if test_url else ""
body.append([
InlineText(str(index)),
InlineText(entry.title),
InlineText(entry.published),
article,
youtube,
challenge,
notebook,
test
)
])
index += 1
return body
122 changes: 0 additions & 122 deletions generate_docs/markdown.py

This file was deleted.

Loading

0 comments on commit fefd6a4

Please sign in to comment.