Got rst docs working with pypi

This commit is contained in:
Owais Lone 2016-11-07 03:15:13 +05:30
parent 51a4761f61
commit c81d425f19
6 changed files with 26 additions and 18 deletions

3
.gitignore vendored
View file

@ -1,5 +1,8 @@
venv/ venv/
# auto generated
README.rst
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
*.py[cod] *.py[cod]

View file

@ -5,6 +5,7 @@ PROJECT = webpack-loader
# Virtual environment settings # Virtual environment settings
ENV ?= venv ENV ?= venv
REPOSITORY ?= test-pypi
requirements = -r requirements-dev.txt requirements = -r requirements-dev.txt
@ -24,6 +25,13 @@ install:
@[ ! -d $(ENV)/ ] && virtualenv $(ENV)/ || : @[ ! -d $(ENV)/ ] && virtualenv $(ENV)/ || :
@$(ENV)/bin/pip install $(requirements) @$(ENV)/bin/pip install $(requirements)
publish: build generate-rst:
@pandoc --from=markdown --to=rst --output=README.rst README.md
publish: generate-rst build
@echo "Publishing to pypi..." @echo "Publishing to pypi..."
@$(ENV)/bin/twine upload dist/* @$(ENV)/bin/twine upload -r $(REPOSITORY) dist/*
register:
@echo "Registering package on pypi..."
@$(ENV)/bin/twine register -r $(REPOSITORY)

View file

@ -5,6 +5,7 @@
[![Coverage Status](https://coveralls.io/repos/owais/django-webpack-loader/badge.svg?branch=master&service=github)](https://coveralls.io/github/owais/django-webpack-loader?branch=master) [![Coverage Status](https://coveralls.io/repos/owais/django-webpack-loader/badge.svg?branch=master&service=github)](https://coveralls.io/github/owais/django-webpack-loader?branch=master)
<br> <br>
Read http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a detailed step by step guide on setting up webpack with django using this library. Read http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a detailed step by step guide on setting up webpack with django using this library.
@ -50,6 +51,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
``` ```
<br> <br>
Assuming `assets/` is in `settings.STATICFILES_DIRS` like Assuming `assets/` is in `settings.STATICFILES_DIRS` like
```python ```python
@ -59,6 +61,7 @@ STATICFILES_DIRS = (
``` ```
<br> <br>
Assuming your webpack config lives at `./webpack.config.js` and looks like this Assuming your webpack config lives at `./webpack.config.js` and looks like this
```javascript ```javascript
var path = require("path"); var path = require("path");
@ -81,6 +84,7 @@ module.exports = {
<br> <br>
### Default Configuration ### Default Configuration
```python ```python
WEBPACK_LOADER = { WEBPACK_LOADER = {
@ -170,12 +174,12 @@ and your webpack config is located at `/home/src/webpack.config.js`, then the va
## Usage ## Usage
<br> <br>
#### Manually run webpack to build assets. ### Manually run webpack to build assets.
One of the core principles of django-webpack-loader is to not manage webpack itself in order to give you the flexibility to run webpack the way you want. If you are new to webpack, check one of the [examples](https://github.com/owais/django-webpack-loader/tree/master/examples), read [my detailed blog post](http://owaislone.org/blog/webpack-plus-reactjs-and-django/) or check [webpack docs](http://webpack.github.io/). One of the core principles of django-webpack-loader is to not manage webpack itself in order to give you the flexibility to run webpack the way you want. If you are new to webpack, check one of the [examples](https://github.com/owais/django-webpack-loader/tree/master/examples), read [my detailed blog post](http://owaislone.org/blog/webpack-plus-reactjs-and-django/) or check [webpack docs](http://webpack.github.io/).
#### Settings ### Settings
Add `webpack_loader` to `INSTALLED_APPS` Add `webpack_loader` to `INSTALLED_APPS`
@ -186,7 +190,7 @@ INSTALLED_APPS = (
) )
``` ```
#### Templates ### Templates
```HTML+Django ```HTML+Django
{% load render_bundle from webpack_loader %} {% load render_bundle from webpack_loader %}
@ -215,7 +219,7 @@ INSTALLED_APPS = (
<br> <br>
#### Multiple webpack projects ### Multiple webpack projects
Version 2.0 and up of webpack loader also supports multiple webpack configurations. The following configuration defines 2 webpack stats files in settings and uses the `config` argument in the template tags to influence which stats file to load the bundles from. Version 2.0 and up of webpack loader also supports multiple webpack configurations. The following configuration defines 2 webpack stats files in settings and uses the `config` argument in the template tags to influence which stats file to load the bundles from.
@ -255,7 +259,7 @@ WEBPACK_LOADER = {
</head> </head>
``` ```
#### File URLs instead of html tags ### File URLs instead of html tags
If you need the URL to an asset without the HTML tags, the `get_files` If you need the URL to an asset without the HTML tags, the `get_files`
template tag can be used. A common use case is specifying the URL to a template tag can be used. A common use case is specifying the URL to a
@ -276,7 +280,7 @@ CKEDITOR.config.contentsCss = '{{ editor_css_files.0.publicPath }}';
</ul> </ul>
``` ```
#### Refer other static assets ### Refer other static assets
`webpack_static` template tag provides facilities to load static assets managed by webpack `webpack_static` template tag provides facilities to load static assets managed by webpack
in django templates. It is like django's built in `static` tag but for webpack assets instead. in django templates. It is like django's built in `static` tag but for webpack assets instead.
@ -350,7 +354,7 @@ TEMPLATES = [
Then in your base jinja template: Then in your base jinja template:
```HTML+Jinja2 ```HTML
{{ render_bundle('main') }} {{ render_bundle('main') }}
``` ```

View file

@ -3,4 +3,3 @@ Django==1.10.1
django-jinja==2.2.1 django-jinja==2.2.1
django-jinja2==0.1 django-jinja2==0.1
unittest2==1.1.0 unittest2==1.1.0
pypandoc==1.2.0

View file

@ -1,2 +1,2 @@
[metadata] [metadata]
description-file = README.md description-file = README.rst

View file

@ -8,12 +8,7 @@ def rel(*parts):
'''returns the relative path to a file wrt to the current directory''' '''returns the relative path to a file wrt to the current directory'''
return os.path.abspath(os.path.join(os.path.dirname(__file__), *parts)) return os.path.abspath(os.path.join(os.path.dirname(__file__), *parts))
try: README = open('README.rst', 'r').read()
import pypandoc
README = pypandoc.convert('README.md', 'rst')
except OSError, ImportError:
with open(rel('README.md')) as handler:
README = handler.read()
with open(rel('webpack_loader', '__init__.py')) as handler: with open(rel('webpack_loader', '__init__.py')) as handler:
INIT_PY = handler.read() INIT_PY = handler.read()
@ -26,7 +21,6 @@ setup(
packages = ['webpack_loader', 'webpack_loader/templatetags', 'webpack_loader/contrib'], packages = ['webpack_loader', 'webpack_loader/templatetags', 'webpack_loader/contrib'],
version = VERSION, version = VERSION,
description = 'Transparently use webpack with django', description = 'Transparently use webpack with django',
long_description=README,
author = 'Owais Lone', author = 'Owais Lone',
author_email = 'hello@owaislone.org', author_email = 'hello@owaislone.org',
download_url = 'https://github.com/owais/django-webpack-loader/tarball/{0}'.format(VERSION), download_url = 'https://github.com/owais/django-webpack-loader/tarball/{0}'.format(VERSION),