DEV Community

Cover image for New SSG Feature: Support config file
Japneet Singh
Japneet Singh

Posted on

New SSG Feature: Support config file

Finding the code to work

I was trying to find a teammate to work on each other's code. Professor suggested some repositories to get started. I never thought I would choose a python project as I don't have any experience in this language. However, I asked AndreiSSG if anyone was working on his project. After he confirmed no one created an issue. I immediately made request to work.issue#13

NEW FEATURE

A user could run the SSG by doing either of the following:

# Option 1: use command line arguments:
ssg --input ./site --output ./build --stylesheet https://cdn.jsdelivr.net/npm/water.css@2/out/water.css --lang fr

# Option 2: use a config file
ssg --config ./ssg-config.json
Enter fullscreen mode Exit fullscreen mode

The config file option means we can have a much shorter command, and instead store our options in a file.

Writing & Testing code in python

After I forked the project, I thought not to take much time to write code on python. The problem was the packages required to run and took some time for me to figure out. I had mac OS that had a different version of python installed after reinstallation, it worked. I started studying code and was surprised to know its similarity with swift. I copied similar structures and made some small changes. Then, I looked for reading JSON files in python on the internet. I was able to find the web link to read the JSON file: geeksforgeeks.

# Python program to read
# json file

import JSON

# Opening JSON file
f = open('data.json',)

# returns JSON object as
# a dictionary
data = json.load(f)

# Iterating through the json
# list
for i in data['emp_details']:
    print(i)

# Closing file
f.close()
Enter fullscreen mode Exit fullscreen mode

I was able to write code without any issues. However, testing was a bit tricky as I had to undergo a lot of changes and exceptions.

Tackle the problems

I didn't have many challenges. The only thing is having code tested for all outcomes and avoid any mistakes. Because after merging, it is not good practice to re-edit code. So, reviewing code is very important while developing.

Using git

Well, working with git can be trickier. However, I didn't find it difficult practising with git and followed notes provided by professor. I merged it into my code and made a push request to the master. I wanted the owner to test before merge to the original repository. So, I created a draft pull request for the owner to read and verifyPR.

Conclusion

It was not easy to work with an unfamiliar language yet, working in open source helps you a lot in terms of learning new rules. I have learnt, the syntax is different in every language. The technique and ideas to build are the same.
FinalCode

Top comments (0)