Skip to content

Commit

Permalink
Merge pull request #193 from Nishu0/main
Browse files Browse the repository at this point in the history
Created CONTRIBUTING with emojis
  • Loading branch information
arnaudmiribel committed Nov 2, 2023
2 parents 657f283 + 5adb60a commit f656c13
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 63 deletions.
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
exclude: >
(?x)^(
.*\.md|
)$
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.237
Expand All @@ -21,4 +26,4 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
- id: trailing-whitespace
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing your own extra

In this guide, you'll learn how to publish a new Streamlit extra, either from a new function or an existing package. Let's get started!

## Requirements

Set up linting to standardize your code by running `pre-commit install`, which will then check the formatting of the files you added.

## Case 1: From a new function (not yet on PyPi)

1. Create an empty directory for your extra in the `src/streamlit_extras` directory.

2. Add a `__init__.py` file to provide metadata that will appear in our docs.

```python
# extras/<extra_name>/__init__.py
from .. import extra

@extra # this will register your function's extra
def my_main_function():
...

def example():
...

__title__ = "Great title!" # title of your extra! 🏆
__desc__ = "Great description" # description of your extra! 💡
__icon__ = "🔭" # give your extra an icon! 🌠
__examples__ = [example] # create some examples to show how cool your extra is! 🚀
__author__ = "Eva Jensen"
__experimental_playground__ = False # Optional

```

3. To test it out, run `pip install -e .` in the `streamlit-extras` directory, and then `streamlit run gallery/streamlit_app.py` app.

4. Submit a PR and share your extra with the world! 🎉

## Case 2: From an existing package (already in PyPi)

Create an empty directory for your extra in the src/streamlit_extras directory.

Add a __init__.py file and import your main function from your package.

```python
# extras/<extra_name>/__init__.py

from my_package import my_main_function
from .. import extra

my_main_function = extra(my_main_function)

def example():
...

__title__ = "Great title!" # title of your extra! 🏆
__desc__ = "Great description" # description of your extra! 💡
__icon__ = "🔭" # give your extra an icon! 🌠
__examples__ = [example] # create some examples to show how cool your extra is! 🚀
__author__ = "Eva Jensen"
__pypi_name__ = "my-cool-package"
__package_name__ = "my_package"
__github_repo__ = "evajensen/my-repo" # Optional
__streamlit_cloud_url__ = "http://my-super-app.streamlitapp.com" # Optional
__experimental_playground__ = False # Optional

```

1. Add your package to the list of dependencies in pyproject.toml.

2. (Optional) You can add a "featured-extra" badge to your original README.md if you like!

3. To check that your package has all the required fields, run `poetry run pytest` from the repository.

4. Submit a PR and share your extra with the world! 🎉

## Help

If you are having troubles, create an issue or [DM me on Twitter](https://twitter.com/arnaudmiribel)!


62 changes: 0 additions & 62 deletions docs/contributing.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/contributing.md

0 comments on commit f656c13

Please sign in to comment.