DEV Community

Cover image for The World Of PR's
Antonio-Bennett
Antonio-Bennett

Posted on

The World Of PR's

Background

If you've been following my blog then you know that I have created an extremely simple static site generator in Rust. That blog can be found here for more info. This week we were tasked with filing a PR on a fellow student's repo to add markdown file support and basic parsing.

RomanStaticSG

Welcome to Romans Static Site Generator v.0.1

About RomanStaticSG

RomanStaticSG is made in python. It is a simple static site generator. It accepts an input file, or input folder. The current file types that are parsed are text and markdown. Markdown however currently only supports heading level 1 parsing. The program will then take the accepted files and create basic html webpages, as well as an index.html file. The script also allows you to input a custom output directory, so that the files could be saved in a custom location.

How to Use RomanStaticSG

Python 3.9+ Required
To use RomanStaticSG simply type

python romanssg.py --help

When running the command input command and not specifying the output command, a local folder named "dist" will be created in the directory of the existing file

Command List

Help Screen

python romanssg.py --help  |  python romanssg.py -h
Help Screen  
Usage: python romanssg.py
Commands:

Steps Taken

To get started on making the pull request I first filed an issue detailing what I would be working on.

Add initial Markdown Support #12

With this feature, RomanStaticSG will be able to convert markdown files as well to HTML files starting with Heading leave 1 marking working for now

The first step I made was actually filing a new issue...I found that the previous logic would not work because all files in the current dir with the same file ending would be added to dist.
E.g python romanssg.py -i=example <- All files that are the same filetypes as example would be added to the dist folder. This is because the previous logic found all files that was the same filetype the directory and added them to files to be processed.

Single txt file conversion behaves as directory #13

When running the program if the input is specified as a file the program adds all text files in the same directory as input to the dist folder


for i in os.listdir("."):
    if fnmatch.fnmatch(i, "*.txt"):
    arrayOfFiles.append(i)

Changed to

filename = curr_value <-- input
arrayOfFiles.append(filename)
Enter fullscreen mode Exit fullscreen mode

Next I moved on to adding markdown support. All I had to do was replace header level 1 tags with h1 tags and append the line to the file

if x.startswith("# "):
    x = x.replace("# ", "<h1>")
    newFile.write("\t" + x + "</h1>\n")
Enter fullscreen mode Exit fullscreen mode

Small changes were made to the README as well to indicate that markdown file support was introduced with header level 1 parsing. This was all done with the below PR

Added initial markdown parsing #14

Parses heading level 1 markings in markdown files

Overall Experience

The overall experience was fun. It was interesting seeing the workflow of forking, modifying and submitting PR's and also having them reviewed. Next time I hope to start working on PR's earlier because having a short time frame introduces the opportunity to make mistakes or miss test cases....which I probably have...

Thanks for reading! :)

Discussion (1)

Collapse
aatmaj profile image
Aatmaj • Edited

Cool!