DEV Community

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

Posted on • Updated 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.

https://github.com/roman-rezinkin/RomanStaticSG

Steps Taken

To get started on making the pull request I first filed an issue detailing what I would be working on.
https://github.com/roman-rezinkin/RomanStaticSG/issues/12

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.
https://github.com/roman-rezinkin/RomanStaticSG/issues/13

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

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

https://github.com/roman-rezinkin/RomanStaticSG/pull/14

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! :)

Top comments (1)

Collapse
 
aatmaj profile image
Aatmaj • Edited

Cool!