docs: Add all commands help

This change add gnocchi.rst with all commands help.
And validate the doc with doc8.

Change-Id: I1b7c8f675165d3d193d28b06357c05ad01c3a901
This commit is contained in:
Mehdi Abaakouk 2017-01-24 10:36:41 +01:00
parent 5f2a369713
commit 1ef64d5fd5
6 changed files with 52 additions and 26 deletions

1
.gitignore vendored
View File

@ -55,3 +55,4 @@ ChangeLog
# generated docs
doc/source/api
doc/source/gnocchi.rst

View File

@ -26,6 +26,7 @@ sys.path.insert(0, BASE_DIR)
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'gnocchiclient.gendoc',
'sphinx.ext.autodoc',
#'sphinx.ext.intersphinx'
]

View File

@ -7,6 +7,9 @@ The :program:`gnocchi` shell utility
The :program:`gnocchi` shell utility interacts with Gnocchi from the command
line. It supports the entirety of the Gnocchi API.
Authentication method
+++++++++++++++++++++
You'll need to provide the authentication method and your credentials to
:program:`gnocchi`.
@ -44,8 +47,8 @@ in your environment::
Basic authentication
~~~~~~~~~~~~~~~~~~~~
If you're using Gnocchi with basic authentication, export the following variables
in your environment::
If you're using Gnocchi with basic authentication, export the following
variables in your environment::
export OS_AUTH_TYPE=gnocchi-basic
export GNOCCHI_USER=<youruserid>
@ -82,28 +85,8 @@ environment variables::
export GNOCCHI_USER_ID=99aae-4dc2-4fbc-b5b8-9688c470d9cc
export GNOCCHI_PROJECT_ID=c8d27445-48af-457c-8e0d-1de7103eae1f
Usage
=====
Once authentication is set up, all shell commands take the form::
Commands descriptions
+++++++++++++++++++++
gnocchi <command> [arguments...]
Run :program:`gnocchi help` to get a full list of all possible commands,
and run :program:`gnocchi help <command>` to get detailed help for that
command.
Examples
--------
Create a resource::
gnocchi resource create --attribute id:5a301761-f78b-46e2-8900-8b4f6fe6675a --attribute project_id:eba5c38f-c3dd-4d9c-9235-32d430471f94 -n temperature:high instance
List resources::
gnocchi resource list --type instance
Search of resources::
gnocchi resource search "project_id='5a301761-f78b-46e2-8900-8b4f6fe6675a' and type=instance"
.. include:: gnocchi.rst

36
gnocchiclient/gendoc.py Normal file
View File

@ -0,0 +1,36 @@
# -*- encoding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
from os_doc_tools import commands
# HACK(jd) Not sure why but Sphinx setup this multiple times, so we just avoid
# doing several times the requests by using this global variable :(
_RUN = False
def setup(app):
global _RUN
if _RUN:
return
commands.document_single_project("gnocchi", "doc/source", False)
with open("doc/source/gnocchi.rst", "r") as f:
data = f.read().splitlines(True)
for index, line in enumerate(data):
if "This chapter documents" in line:
break
with open("doc/source/gnocchi.rst", "w") as f:
f.writelines(data[index+1:])
_RUN = True

View File

@ -84,8 +84,10 @@ test =
testtools>=1.4.0
doc =
doc8
sphinx!=1.2.0,!=1.3b1,>=1.1.2
oslosphinx>=2.5.0 # Apache-2.0
openstack-doc-tools>=1.0.1
[build_sphinx]

View File

@ -31,12 +31,15 @@ deps = .[test,doc]
commands =
rm -rf doc/source/ref
python setup.py build_sphinx
doc8 --ignore-path doc/source/gnocchi.rst doc/source
[testenv:docs-gnocchi.xyz]
deps = .[test,doc]
sphinx_rtd_theme
setenv = SPHINX_HTML_THEME=sphinx_rtd_theme
commands = python setup.py build_sphinx
commands =
python setup.py build_sphinx
doc8 --ignore-path doc/source/gnocchi.rst doc/source
[testenv:debug]
commands = pifpaf --debug run gnocchi -- oslo_debug_helper {posargs}