More API documentation

This commit is contained in:
Ruud
2012-02-21 20:42:41 +01:00
parent a5cc1859d1
commit b164674ff7
7 changed files with 88 additions and 31 deletions
+6 -9
View File
@@ -33,15 +33,12 @@ class Updater(Plugin):
'desc': 'Get updater information',
'return': {
'type': 'object',
'example': """
{
'repo_name': "Name of used repository",
'last_check': "last checked for update",
'update_version': "available update version or empty",
'version': current_cp_version
}
"""
}
'example': """{
'repo_name': "Name of used repository",
'last_check': "last checked for update",
'update_version': "available update version or empty",
'version': current_cp_version
}"""}
})
addApiView('updater.update', self.doUpdateView)
addApiView('updater.check', self.checkView, docs = {
+22 -4
View File
@@ -58,10 +58,28 @@ class MoviePlugin(Plugin):
}
})
addApiView('movie.available_chars', self.charView)
addApiView('movie.add', self.addView)
addApiView('movie.edit', self.edit)
addApiView('movie.delete', self.delete)
addApiView('movie.add', self.addView, docs = {
'desc': 'Add new movie to the wanted list',
'params': {
'identifier': {'desc': 'IMDB id of the movie your want to add.'},
'profile_id': {'desc': 'ID of quality profile you want the add the movie in. If empty will use the default profile.'},
'title': {'desc': 'Movie title to use for searches. Has to be one of the titles returned by movie.search.'},
}
})
addApiView('movie.edit', self.edit, docs = {
'desc': 'Add new movie to the wanted list',
'params': {
'id': {'desc': 'Movie ID you want to edit'},
'profile_id': {'desc': 'ID of quality profile you want the edit the movie to.'},
'default_title': {'desc': 'Movie title to use for searches. Has to be one of the titles returned by movie.search.'},
}
})
addApiView('movie.delete', self.delete, docs = {
'desc': 'Delete a movie from the wanted list',
'params': {
'id': {'desc': 'Movie ID you want to delete'},
}
})
addEvent('movie.add', self.add)
addEvent('movie.get', self.get)
+12 -2
View File
@@ -16,8 +16,18 @@ class Release(Plugin):
def __init__(self):
addEvent('release.add', self.add)
addApiView('release.download', self.download)
addApiView('release.delete', self.delete)
addApiView('release.download', self.download, docs = {
'desc': 'Send a release manually to the downloaders',
'params': {
'id': {'type': 'id', 'desc': 'ID of the release object in release-table'}
}
})
addApiView('release.delete', self.delete, docs = {
'desc': 'Check for available update',
'params': {
'id': {'type': 'id', 'desc': 'ID of the release object in release-table'}
}
})
def add(self, group):
db = get_session()
+4 -2
View File
@@ -22,7 +22,9 @@ class Renamer(Plugin):
def __init__(self):
addApiView('renamer.scan', self.scanView)
addApiView('renamer.scan', self.scanView, docs = {
'desc': 'For the renamer to check for new files to rename',
})
addEvent('renamer.scan', self.scan)
addEvent('app.load', self.scan)
@@ -31,7 +33,7 @@ class Renamer(Plugin):
def scanView(self):
fireEvent('renamer.scan')
fireEventAsync('renamer.scan')
return jsonified({
'success': True
+7 -1
View File
@@ -29,7 +29,13 @@ class StatusPlugin(Plugin):
addEvent('status.all', self.all)
addEvent('app.initialize', self.fill)
addApiView('status.list', self.list)
addApiView('status.list', self.list, docs = {
'desc': 'Check for available update',
'return': {'type': 'object', 'example': """{
'success': True,
'list': array, statuses
}"""}
})
def list(self):
+31 -9
View File
@@ -1,3 +1,4 @@
html {
font-size: 12px;
line-height: 1.5;
@@ -5,15 +6,22 @@ html {
font-size: 14px;
}
* {
margin: 0;
padding: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
h1, h2, h3, h4, h5 {
clear: both;
padding: 0;
margin: 0;
font-size: 14px;
}
h1 {
font-size: 25px;
padding: 20px 40px;
}
h2 {
@@ -21,18 +29,23 @@ h2 {
}
pre {
background: #ccc;
background: #eee;
font-family: monospace;
margin: 0;
padding: 2%;
width: 96%;
padding: 10px;
width: 100%;
display: block;
font-size: 12px;
}
.api {
margin-bottom: 20px;
.api, .missing {
overflow: hidden;
border-bottom: 1px solid #eee;
padding: 40px;
}
.api:hover {
color: #000;
}
.api .description {
color: #333;
@@ -40,7 +53,7 @@ pre {
}
.api .params {
background: #f5f5f5;
background: #fafafa;
width: 100%;
}
.api h3 {
@@ -54,6 +67,14 @@ pre {
width: 700px;
}
.api .params td, .api .params th {
padding: 3px 5px;
border-bottom: 1px solid #eee;
}
.api .params tr:last-child td, .api .params tr:last-child th {
border: 0;
}
.api .params .param {
vertical-align: top;
}
@@ -67,9 +88,10 @@ pre {
font-style: italic;
margin-right: 10px;
width: 100px;
color: #666;
}
.api .return {
float: left;
width: 700px;
}
}
+6 -4
View File
@@ -6,7 +6,7 @@
</head>
<body>
<h1>API</h1>
<h1>CouchPotato API Documentation</h1>
{% for route in routes %}
{% if api_docs.get(route) %}
<div class="api">
@@ -15,7 +15,7 @@
{% if api_docs[route].get('params') %}
<h3>Params</h3>
<table class="params">
<table class="params" cellspacing="0" cellpadding="0">
{% for param in api_docs[route]['params'] %}
<tr class="param">
<th>{{param}}</th>
@@ -42,8 +42,10 @@
{% endif %}
{% endfor %}
<h1>Missing documentation</h1>
<div class="missing">{{', '.join(api_docs_missing)}}</div>
<div class="missing">
<h1>Missing documentation</h1>
{{', '.join(api_docs_missing)}}
</div>
</body>
</html>