Skip to content

Commit 6f9dcc1

Browse files
author
Dean Troyer
committed
Prep for 0.2 release (0.2.rc1)
* rename HACKING to HACKING.rst and refer to the common OpenStack HACKING file * add the barest of pointers to the wiki, etc. to the source docs * add a bare-bones man page Change-Id: I80e5b972af645f14ef17ae87f182ab09cb08dabe
1 parent 22386eb commit 6f9dcc1

File tree

9 files changed

+315
-155
lines changed

9 files changed

+315
-155
lines changed

HACKING

Lines changed: 0 additions & 122 deletions
This file was deleted.

HACKING.rst

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
OpenStack Style Commandments
2+
============================
3+
4+
Step 0: Read https://github.com/openstack-dev/hacking/blob/master/HACKING.rst
5+
Step 1: Read http://www.python.org/dev/peps/pep-0008/ one more time
6+
Step 2: Read on
7+
8+
General
9+
-------
10+
- thou shalt not violate causality in our time cone, or else
11+
12+
Docstrings
13+
----------
14+
15+
Docstrings should ONLY use triple-double-quotes (``"""``)
16+
17+
Single-line docstrings should NEVER have extraneous whitespace
18+
between enclosing triple-double-quotes.
19+
20+
Deviation! Sentence fragments do not have punctuation. Specifically in the
21+
command classes the one line docstring is also the help string for that
22+
command and those do not have periods.
23+
24+
"""A one line docstring looks like this"""
25+
26+
Calling Methods
27+
---------------
28+
29+
Deviation! When breaking up method calls due to the 79 char line length limit,
30+
use the alternate 4 space indent. With the frist argument on the succeeding
31+
line all arguments will then be vertically aligned. Use the same convention
32+
used with other data structure literals and terminate the method call with
33+
the last argument line ending with a comma and the closing paren on its own
34+
line indented to the starting line level.
35+
36+
unnecessarily_long_function_name(
37+
'string one',
38+
'string two',
39+
kwarg1=constants.ACTIVE,
40+
kwarg2=['a', 'b', 'c'],
41+
)
42+
43+
Text encoding
44+
-------------
45+
46+
Note: this section clearly has not been implemented in this project yet, it is
47+
the intention to do so.
48+
49+
All text within python code should be of type 'unicode'.
50+
51+
WRONG:
52+
53+
>>> s = 'foo'
54+
>>> s
55+
'foo'
56+
>>> type(s)
57+
<type 'str'>
58+
59+
RIGHT:
60+
61+
>>> u = u'foo'
62+
>>> u
63+
u'foo'
64+
>>> type(u)
65+
<type 'unicode'>
66+
67+
Transitions between internal unicode and external strings should always
68+
be immediately and explicitly encoded or decoded.
69+
70+
All external text that is not explicitly encoded (database storage,
71+
commandline arguments, etc.) should be presumed to be encoded as utf-8.
72+
73+
WRONG:
74+
75+
mystring = infile.readline()
76+
myreturnstring = do_some_magic_with(mystring)
77+
outfile.write(myreturnstring)
78+
79+
RIGHT:
80+
81+
mystring = infile.readline()
82+
mytext = s.decode('utf-8')
83+
returntext = do_some_magic_with(mytext)
84+
returnstring = returntext.encode('utf-8')
85+
outfile.write(returnstring)
86+
87+
Python 3.x Compatibility
88+
------------------------
89+
90+
OpenStackClient strives to be Python 3.3 compatibile. Common guidelines:
91+
92+
* Convert print statements to functions: print statements should be converted
93+
to an appropriate log or other output mechanism.
94+
* Use six where applicable: x.iteritems is converted to six.iteritems(x)
95+
for example.
96+
97+
Running Tests
98+
-------------
99+
100+
Note: Oh boy, are we behing on writing tests. But they are coming!
101+
102+
The testing system is based on a combination of tox and testr. If you just
103+
want to run the whole suite, run `tox` and all will be fine. However, if
104+
you'd like to dig in a bit more, you might want to learn some things about
105+
testr itself. A basic walkthrough for OpenStack can be found at
106+
http://wiki.openstack.org/testr

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ For issue tracking::
2626

2727
* https://bugs.launchpad.net/python-openstackclient
2828

29+
Note
30+
====
31+
32+
OpenStackClient is considered to be alpha release quality as of the 0.2 release;
33+
no assurances are made at this point for ongoing compatibility in command forms
34+
or output. We do not, however, expect any major changes at this point.
35+
2936
Getting Started
3037
===============
3138

doc/source/commands.rst

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,50 @@
22
Commands
33
========
44

5+
56
Command Structure
67
=================
78

8-
OpenStack Client uses a command form ``verb object``.
9-
10-
Note that 'object' here refers to the target of a command's action. In coding
11-
discussions 'object' has its usual Python meaning. Go figure.
9+
OpenStackClient has a consistent and predictable format for all of its commands.
1210

1311
Commands take the form::
1412

15-
openstack [<global-options>] <verb> <object> [<command-local-arguments>]
13+
openstack [<global-options>] <object> <action> [<second-object>] [<command-arguments>]
14+
15+
* All long options names begin with two dashes ('--') and use a single dash ('-') internally between words (--like-this)
16+
17+
18+
Global Options
19+
--------------
20+
21+
Global options are global in the sense that the apply to every command invocation regardless of action to be performed. This includes authentication credentials and API version selection. Most global options have a corresponding environment variable that may also be used to set the value. If both are present, the command-line option takes priority. The environment variable names are derived from the option name by dropping the leading dashes ('--'), converting each embedded dash ('-') to an underscore ('_'), and converting to upper case.
22+
23+
For example, ``--os-username`` can be set from the environment via ``OS_USERNAME``.
24+
25+
26+
Command Object(s) and Action
27+
----------------------------
1628

17-
Command Arguments
18-
-----------------
29+
Commands consist of an object described by one or more words followed by an action.
30+
In commands requiring two objects be acted upon, the primary object appears ahead of the action and the secondary object appears after the action.
31+
If both objects have cooresponding positional arguments the arguments appear in the same order as the objects. In badly formed English it is expressed as "(Take) object1 (and perform) action (using) object2 (to it)."
1932

20-
* All long option names use two dashes ('--') as the prefix and a single dash
21-
('-') as the interpolation character. Some common options also have the
22-
traditional single letter name prefixed by a single dash ('-').
23-
* Global options generally have a corresponding environment variable that
24-
may also be used to set the value. If both are present, the command-line
25-
option takes priority. The environment variable names can be derived from
26-
the option name by dropping the leading '--', converting all embedded dashes
27-
('-') to underscores ('_'), and converting the name to upper case.
28-
* Positional arguments trail command options. In commands that require two or
29-
more objects be acted upon, such as 'attach A to B', both objects appear
30-
as positional arguments. If they also appear in the command object they are
31-
in the same order.
33+
::
34+
35+
<object-1> <action> <object-2>
36+
37+
Examples::
38+
39+
group add user <group> <user>
40+
41+
volume type list # 'volume type' is a two-word single object
42+
43+
44+
Command Arguments and Options
45+
-----------------------------
46+
47+
Commands have their own set of options distinct from the global options. They follow the
48+
same style as the global options and always appear between the command and any positional arguemnts the command may require.
3249

3350

3451
Implementation
@@ -38,6 +55,7 @@ The command structure is designed to support seamless addition of extension
3855
command modules via entry points. The extensions are assumed to be subclasses
3956
of Cliff's command.Command object.
4057

58+
4159
Command Entry Points
4260
--------------------
4361

doc/source/conf.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
import os
1616
import sys
1717

18+
import pbr.version
19+
1820
# If extensions (or modules to document with autodoc) are in another directory,
1921
# add these directories to sys.path here. If the directory is relative to the
2022
# documentation root, use os.path.abspath to make it absolute, like shown here.
21-
#sys.path.insert(0, os.path.abspath('.'))
23+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
2224

2325
# -- General configuration ----------------------------------------------------
2426

@@ -46,16 +48,18 @@
4648

4749
# General information about the project.
4850
project = u'OpenStack Command Line Client'
49-
copyright = u'2012, OpenStack'
51+
copyright = u'2012-2013 OpenStack Foundation'
5052

5153
# The version info for the project you're documenting, acts as replacement for
5254
# |version| and |release|, also used in various other places throughout the
5355
# built documents.
5456
#
57+
version_info = pbr.version.VersionInfo('python-openstackclient')
58+
#
5559
# The short X.Y version.
56-
version = '0.1'
60+
version = version_info.version_string()
5761
# The full version, including alpha/beta/rc tags.
58-
release = '0.1'
62+
release = version_info.release_string()
5963

6064
# The language for content autogenerated by Sphinx. Refer to documentation
6165
# for a list of supported languages.
@@ -221,9 +225,13 @@
221225
# One entry per manual page. List of tuples
222226
# (source start file, name, description, authors, manual section).
223227
man_pages = [
224-
('index', 'openstackcommandlineclient',
225-
u'OpenStack Command Line Client Documentation',
226-
[u'OpenStack'], 1)
228+
(
229+
'man/openstack',
230+
'openstack',
231+
u'OpenStack Command Line Client',
232+
[u'OpenStack contributors'],
233+
1,
234+
),
227235
]
228236

229237
# If true, show URL addresses after external links.

0 commit comments

Comments
 (0)