masfaraud / BMSpy

Python Block-Model Simulator. An alternative to simulink in python.
GNU Lesser General Public License v3.0
222 stars 36 forks source link

Create a CONTRIBUTING file (or include contributing info on README) #20

Open ericonr opened 5 years ago

ericonr commented 5 years ago

Hey there, back again!

Seeing as there are at least three different contributors to the project, it would be nice if there was a guideline for contributing to the project, such as docstring styles, formatting, and other stuff. Seeing as you are the owner of the project, I believe it would be best if you decided on it. If you want, I can write one based on what you decide. Making the project follow a certain standard makes it easier for new contributors to get used to the code.

Things like spacing between operators and values, tabs-vs-spaces, maximum number of characters per line, could be included.

Regarding docstrings, I'm partial to the following style, using Google docstring formatting and .. math for displaying formulas:

class Saturation(Block):
    """Defines a saturation block.
    .. math::
        output = 
        \\begin{cases}
            min\_value, & \\textrm{if } input < min\_value
            max\_value, & \\textrm{if } input > max\_value
            input, & \\textrm{if } min\_value \leq input \leq max\_value
        \\end{cases}
    Args:
        input_variable (Variable): This is the input of the block.
        output_variable (Variable): This is the output of the block.
        min_value: This is the lower bound for the output.
        max_value: This is the upper bound for the output.
    """
masfaraud commented 5 years ago

Thanks for the suggestion. For docstrings do you know if this format is recognized by sphinx?

ericonr commented 5 years ago

I have added the necessary option to the sphinx Makefile, so it renders it beautifully. As can be seen in the generated documentation for the Saturation block here.