Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
- change default value for allowed flags to 10.
- correct some grammatical errors in readme.
- add badges for read the docs, python and django versions.

.
  • Loading branch information
abhiabhi94 committed Sep 27, 2020
1 parent 57868ea commit e72745b
Show file tree
Hide file tree
Showing 17 changed files with 532 additions and 136 deletions.
53 changes: 38 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
django-flag-app
===============

.. image:: https://img.shields.io/github/license/abhiabhi94/django-flag-app?color=gr
:target: https://github.com/abhiabhi94/django-flag-app/blob/master/LICENSE
:alt: licence

.. image:: https://travis-ci.org/abhiabhi94/django-flag-app.svg?branch=master
:target: https://travis-ci.org/abhiabhi94/django-flag-app
:alt: build
Expand All @@ -14,11 +10,32 @@ django-flag-app
:target: https://coveralls.io/github/abhiabhi94/django-flag-app
:alt: coverage

A pluggable django application to add flagging to your models.
.. image:: https://img.shields.io/pypi/pyversions/django-flag-app.svg
:target: https://pypi.python.org/pypi/django-flag-app/
:alt: python

.. image:: https://img.shields.io/pypi/djversions/django-flag-app.svg
:target: https://pypi.python.org/pypi/django-flag-app/
:alt: django

.. image:: https://readthedocs.org/projects/django-flag-app/badge/?version=latest
:target: https://django-flag-app.readthedocs.io/?badge=latest
:alt: docs

.. image:: https://img.shields.io/github/license/abhiabhi94/django-flag-app?color=gr
:target: https://github.com/abhiabhi94/django-flag-app/blob/master/LICENSE
:alt: licence

A pluggable django application that adds the ability for users to flag(or report) your models.

.. image:: ./docs/_static/images/django-flag-app.gif
:alt: flagging-process

For complete documentation you may visit `Read the Doc`_. or see the `docs`_ directory.

.. _Read the Doc: https://django-flag-app.readthedocs.io
.. _docs: ./docs/

Installation
------------

Expand All @@ -39,7 +56,8 @@ If you want, you may install it from the source, grab the source code and run ``
Usage
-----

* Add app
Add app
````````

To enable ``django_flag_app`` in your project you need to add it to ``INSTALLED_APPS`` in your projects ``settings.py`` file:

Expand All @@ -51,10 +69,10 @@ To enable ``django_flag_app`` in your project you need to add it to ``INSTALLED_
...
)
Step-1: Add url
````````````````
Add URL
````````

In ``urls.py``:
In your root ``urls.py``:

.. code:: python
Expand All @@ -66,8 +84,8 @@ In ``urls.py``:
...
)
Step 2: Migrate
````````````````
Migrate
````````

Run the migrations to add the new models to your database:

Expand All @@ -76,8 +94,8 @@ Run the migrations to add the new models to your database:
python manage.py migrate flag
Step 3: Connect the flag model with the target model
`````````````````````````````````````````````````````
Connect the flag model with the target model
`````````````````````````````````````````````

In ``models.py`` add the field **flags** as a ``GenericRelation`` field to the required model.

Expand All @@ -98,8 +116,12 @@ E.g. for a ``Post`` model, you may add the field as shown below:
flags = GenericRelation(Flag)
Step 4: Use template tag
`````````````````````````
Use template tag
`````````````````

If you want to use web API, this step is not required. See further instructions at `Web API`_.

:: _Web API: ./docs/webAPI.rst

``render_flag_form`` tag requires 2 required positional arguments:

Expand All @@ -113,6 +135,7 @@ To render the ``flag`` form for a the instance ``post``, place this inside your
{% render_flag_form post user %}
Contributing
------------

Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
66 changes: 66 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

BASE_DIR = os.path.dirname((os.path.dirname(os.path.abspath(__file__))))


def get_version():
with open(os.path.join(BASE_DIR, 'VERSION')) as version_file:
version = version_file.read().strip()
return version


# -- Project information -----------------------------------------------------

project = 'Django Flag App'
copyright = '2020, Abhyudai'
author = 'Abhyudai'

# The short X.Y version
version = get_version()
# The full version, including alpha/beta/rc tags
release = get_version()


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autosectionlabel',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
48 changes: 48 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
===============================
Contributing to Django Flag App
===============================

There are many ways to contribute to the project. You may improve the documentation, address a bug, add some feature to the code or do something else. All sort of contributions are welcome.


Development
-----------

To start development on this project, fork this repository and follow the following instructions.

.. code:: sh
# clone the forked repository
$ git clone YOUR_FORKED_REPO_URL
# create a virtual environment
$ python3 -m venv venv
# activate the virtual environment
$ source venv/bin/activate
# install dependencies
(venv) $ pip install -e . -r testapp/requirements.txt
# migrate the migrations to the database
(venv) $ python manage.py migrate
# create data
(venv) $ python manage.py create_initial_data
# start the development server
(venv) $ python manage.py runserver
Testing
-------

To run tests against a particular ``python`` and ``django`` version installed inside your virtual environment, you may use:

.. code:: sh
(venv) $ python manage.py test
To run tests against all supported ``python`` and ``django`` versions, you may run:

.. code:: sh
# install dependency
(venv) $ pip install tox
# run tests
(venv) $ tox
21 changes: 21 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Welcome to Django Flag App's documentation!
===========================================

.. toctree::
:maxdepth: 2
:caption: Contents:

introduction
webAPI
settings
style-customisation
contributing



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

0 comments on commit e72745b

Please sign in to comment.