Contributing Guide
Contributing guide to danfo.js including set up guide, and a brief intro to danfo internals.
Contributing to danfojs
Table of contents:
TL:DR
Where to start?
Working with the code
Version control, Git, and GitHub
Getting started with Git
Forking
Creating a development environment
Documentation Guidelines
Writing tests
Using mocha
Running the test suite
Contributing your changes to danfojs
Committing your code
Pushing your changes
Review your code and finally, make the pull request
Danfojs internal (Brief)
TL:DR
All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome.
For contributors familiar with open-source, below is a quick guide to setting up danfojs locally.
There are three main folders in the src
folder, danfojs-base, danfojs-browser, and danfojs-node.
The danfojs-base folder holds all shared classes, modules, and functions used by both danfojs-browser and danfojs-node. So features or bug fixes that work the same way in both versions will generally be done in the danfojs-base folder.
Where to start?
For first-time contributors, you can find pending issues on the GitHub “issues” page. There are a number of issues listed and "good first issue" where you could start out. Once you’ve found an interesting issue, and have an improvement in mind, next thing is to set up your development environment.
Working with the code
If you have an issue you want to fix, an enhancement to add, or documentation to improve, you need to learn how to work with GitHub and the Danfojs code base.
Version control, Git, and GitHub
Danfojs code is hosted on GitHub. To contribute you will need to sign up for a free GitHub account. We use Git for version control to allow many people to work together on this project.
Some great resources for learning Git:
Official GitHub pages.
Getting started with Git
Find Instructions for installing git, setting up your SSH key, and configuring git. These steps need to be completed before you can work seamlessly between your local repository and GitHub.
Forking the Danfojs repo
You will need your own fork to work on the code. Go to the danfojs project page and hit the Fork button.
Next, you will clone your fork to your local machine:
This creates the directory danfojs and connects your repository to the upstream (main project) repository.
Some Javascript features are supported both in the browser and node environment, and it is recommended to add features in the danfojs-base folder.
For features that work differently or only in a specific environment, you can add them in the corresponding danfojs-node or danfojs-browser folder.
Creating a development environment
To test out code changes, you’ll need to build danfojs, which requires a Nodejs environment.
Now you can start adding features or fixing bugs!
Documentation Guidelines
Documentation helps clarify what a function or a method is doing. It also gives insight to users of the function or methods on what parameters to pass in and know what the function will return.
Sample documentation:
And for functions that contain more than two arguments, a keyword argument can be used. Parsing of keyword argument is also applicable to most of the methods in a class
Writing tests
We strongly encourage contributors to write tests for their code. Like many packages, Danfojs uses mocha.
All tests should go into the tests subdirectory and placed in the corresponding module. The tests folder contains some current examples of tests, and we suggest looking to these for inspiration.
Below is the general Framework to write a test for each module.
For a class with lots of methods.
Example: Let write a test, to test if the values in a dataframe are off a certain length. Assuming the method to obtain length is values_len()
Running the test case
To run the test for the module you created,
1) Open the package.json
2) change the name of the test script to the file name you want to test.
3) run the test, in the danfojs directory terminal
Learn more about mocha here
Contributing your changes to danfojs
Committing your code
Once you’ve made changes, you can see them by typing:
Next, you can track your changes using
Next, you commit changes using:
Pushing your changes
When you want your changes to appear publicly on your GitHub page, you can push to your forked repo with:
Review your code and finally, make a pull request
If everything looks good, you are ready to make a pull request. A pull request is how code from a local repository becomes available to the GitHub community and can be reviewed and eventually merged into the master version. To submit a pull request:
Navigate to your repository on GitHub
Click on the Pull Request button
Write a description of your changes in the Preview Discussion tab
Click Send Pull Request.
This request then goes to the repository maintainers, and they will review the code and everything looks good, merge it with the master.
Hooray! You're now a contributor to danfojs. Now go bask in the euphoria!
Danfojs Internals
In other to contribute to the code base of danfojs, there are some functions and properties provided to make implementation easy.
The folder danfojs-base contains the bulk of Danfojs modules, and these are simply extended or exported by the danfojs-browser and danfojs-node folders. The base class for Frames and Series is the NdFrame class which is found in the danfojs-base/core/generic
file.
Last updated