-
Notifications
You must be signed in to change notification settings - Fork 8
/
PKG-INFO
209 lines (153 loc) · 8.2 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
Metadata-Version: 1.1
Name: django_mkdocs
Version: 0.1.2
Summary: MkDocs served by Django for permissioned access
Home-page: UNKNOWN
Author: Rithmio
Author-email: devadmin@rithmio.com
License: LGPL
Description: # django-mkdocs
Django-mkdocs is built on the premise that there is a need for simple, beautiful, maintainable documentation which can be user-permissioned. The app is *heavily inspired* by [django-documentation](https://github.com/Narsil/django-documentation) with updated compatibility for Django 1.10, and uses [MkDocs](http://www.mkdocs.org/) to generate a static-site served by Django.
To be clear, django-mkdocs was not intended for large-scale access. It was originally created to serve documentation internally and to select partners. If your documents are intended to be public, using MkDocs alone with github-pages or Amazon S3 may be a better solution.
## Installation
Django-mkdocs can be installed directly from pip:
```
$ pip install django-mkdocs
```
### Plugging django-mkdocs into your Django project
In your Django project, add 'django_mkdocs' to your settings.py:
```
project/settings.py
INSTALLED_APPS = (
...
'django_mkdocs',
)
```
Add a reference to your projects urls.py:
```
project/urls.py
from django.conf.urls import url, include
...
...
urlpatterns = [
...
url(r'^docs/', include('django_mkdocs.urls', namespace='documentation')),
]
```
### Setting up the MkDocs documentation
MkDocs is included with django-mkdocs. The project naturally has excellent documentation and is linked [here](http://www.mkdocs.org/).
We recommend making a directory for your documentation in the root of your Django project, and starting a MkDocs project in there.
```
$ mkdocs new project_docs
```
Your directory structure should now look something like this:
```
├── manage.py
├── project
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── project_docs
├── docs
│ └── index.md
└── mkdocs.yml
```
The main configuration file for MkDocs is mkdocs.yml. Let's move it into the Django project root for easier builds later on:
```
$ mv project_docs/mkdocs.yml ./mkdocs.yml
```
Now we'll need to change a couple of references in this file.
- **site_name** is the title of your HTML page
- **pages** tells MkDocs your desired site-structure and which markdown files should be used to generate it
- **docs_dir** refers to the markdown your documentation will be generated from, while
- **site_dir** refers to the location where the static site will be generated.
- Lastly, **use_directory_urls** should be set to false for Django's routing to work correctly.
```
mkdocs.yml
site_name: My Docs
pages:
- Home: index.md
use_directory_urls: false
docs_dir: project_docs/docs
site_dir: project_docs/site
```
To build the documentation, run the following command from the directory containing mkdocs.yml. We include the optional *--clean* flag here to signify that site_dir should be cleansed of page references that have been removed from our mkdocs.yml.
```
$ mkdocs build --clean
```
It's also recommended that you add this command to your post-deployment script for fresh document builds each time you deploy.
### Options for serving the documentation
In order to serve your docs, django-mkdocs needs to know where to look for them. These settings must be configured in your project's settings.py. Set the DOCUMENTATION_ROOT to the directory which contains both your **docs_dir** and **site_dir** folders. In this snippet, 'PROJECT_DIR' is the absolute path to our Django project.
```
project/settings.py
# django-mkdocs demo parameters!
PROJECT_DIR = os.path.dirname(os.path.dirname(__file__))
DOCUMENTATION_ROOT = PROJECT_DIR + '/project_docs'
```
DOCUMENTATION_HTML_ROOT points to the root of our statically generated site. This should correspond to the same directory as our mkdocs.yml site_dir.
```
DOCUMENTATION_HTML_ROOT = DOCUMENTATION_ROOT + '/site'
```
DOCUMENTATION_ACCESS_FUNCTION is used in the views that attempt to access the documentation. Django-mkdocs calls DOCUMENTATION_ACCESS_FUNCTION with request.user as an argument. This flag determines who has access to view the docs.
```
DOCUMENTATION_ACCESS_FUNCTION = lambda user: user.is_staff
```
Django-mkdocs assumes an Nginx server is used by default to serve the documentation. DOCUMENTATION_XSENDFILE is set to true by default. If you are not using Nginx, expect a very small number of users, and understand the consequences of using django.views.static.serve, set the following flag:
```
DOCUMENTATION_XSENDFILE = False
```
## Viewing your documentation
With the above steps completed, you should now be able to view your static site at the endpoint defined in your project's urlconf. Let's test this out locally. First, run Django's development server from the project root:
```
$ python manage.py runserver
```
Point your browser to localhost:8000/docs (or the url you referenced). You should now see your generated docs!
NOTE: If following along in the demo project, you may need to run migrations and create a superuser. You will also need to authenticate at the django admin console at localhost:8000/admin after performing the following commands.
```
$ python manage.py migrate
$ python manage.py createsuperuser
```
## Deploying to Heroku
You may also wish to have your documentation build automatically every time you deploy. One way to accomplish this with Heroku is to add a post deployment hook. From the root of your django project, create a directory named bin/, and in that directory, a script named *post_compile*.
```
$ mkdir bin
$ touch bin/post_compile
```
You can add any other shell commands you like, but let's add our build command.
```
bin/post_compile
echo "-----> Building MkDocs documentation"
mkdocs build --clean
```
And your final directory tree should look like this:
```
├── bin
│ └── post_compile
├── manage.py
├── mkdocs.yml
├── project
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── project_docs
├── docs
│ └── index.md
└── site
```
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 1.8
Classifier: Framework :: Django :: 1.9
Classifier: Framework :: Django :: 1.10
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content