feat: layed out language code class
This commit is contained in:
parent
e84828092c
commit
3b042b718f
@ -78,6 +78,23 @@ def convert_md(src: Path, dst: Path, context: Optional[Context] = None):
|
||||
with Path(folder_dst, "index.html").open("w") as f:
|
||||
f.write(full_page)
|
||||
|
||||
|
||||
class CustomLanguageCode:
|
||||
def __init__(self, file: Path):
|
||||
self.file: Path = file
|
||||
|
||||
@property
|
||||
def language_code(self) -> str:
|
||||
return self.file.name.replace(".md", "")
|
||||
|
||||
@property
|
||||
def relative_url(self) -> str:
|
||||
return str(self.file)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{self.language_code}"
|
||||
|
||||
|
||||
def walk_directory(root):
|
||||
src_path = Path(SOURCE_DIRECTORY, root)
|
||||
dst_path = Path(DIST_DIRECTORY, root)
|
||||
@ -95,7 +112,8 @@ def walk_directory(root):
|
||||
|
||||
if current_name.endswith(".md"):
|
||||
convert_md(current_src, current_dst)
|
||||
language_codes_found.append(current_name.replace(".md", ""))
|
||||
|
||||
language_codes_found.append(CustomLanguageCode(Path(root, current_name)))
|
||||
continue
|
||||
|
||||
if current_src.is_dir():
|
||||
|
Loading…
x
Reference in New Issue
Block a user