Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify docs #389

Merged
merged 52 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
688bb3e
fix index links
k0ka Jan 17, 2024
ebf3ad6
check adding index to toc
k0ka Jan 17, 2024
179be75
check adding index to toc
k0ka Jan 17, 2024
ef5df8a
playing with toc
k0ka Jan 17, 2024
807a13b
add OpenStack creation
k0ka Jan 17, 2024
23d1685
add OpenStack creation
k0ka Jan 17, 2024
692b514
fix OpenStack creation
k0ka Jan 17, 2024
ef887d4
fix OpenStack creation
k0ka Jan 17, 2024
09c629f
fix OpenStack creation
k0ka Jan 17, 2024
7cc793c
doc fixes
k0ka Jan 17, 2024
70f27c3
add collapsible auth code
k0ka Jan 17, 2024
dc8d9d6
add collapsible auth code
k0ka Jan 17, 2024
34b838e
add collapsible auth code
k0ka Jan 17, 2024
074efe4
add collapsible auth code
k0ka Jan 17, 2024
6e851df
fix styling
k0ka Jan 17, 2024
4773de8
Merge branch 'master' into rewrite-docs
k0ka Jan 17, 2024
b545ad3
typo
k0ka Jan 17, 2024
d23c1e4
add collapsible auth code
k0ka Jan 18, 2024
67a36de
add collapsible auth code
k0ka Jan 18, 2024
3971434
fix docs
k0ka Jan 18, 2024
200360e
fix docs
k0ka Jan 18, 2024
a8da1e0
fix docs
k0ka Jan 18, 2024
8b2f4e6
remove code example
k0ka Jan 18, 2024
e2da944
testing docs
k0ka Jan 18, 2024
51e45c7
testing docs
k0ka Jan 18, 2024
0f00809
testing docs
k0ka Jan 18, 2024
4287776
testing docs
k0ka Jan 18, 2024
8e9c1b5
testing docs
k0ka Jan 18, 2024
b12a1a0
show authentication samples
k0ka Jan 18, 2024
9cabf4c
fix link
k0ka Jan 18, 2024
92d48d2
credentials doc
k0ka Jan 18, 2024
ee326c7
- add osdoc
k0ka Jan 18, 2024
a313d7c
fix osdoc
k0ka Jan 18, 2024
9cc4929
check include
k0ka Jan 18, 2024
404f581
added service.rst
k0ka Jan 18, 2024
933bf4b
fix documentation for identity v2 and v3
k0ka Jan 19, 2024
a3d2792
clarify auth docs
k0ka Jan 19, 2024
3572575
fix samples
k0ka Jan 19, 2024
090571a
- Block Storage
k0ka Jan 19, 2024
d349536
fix sample name
k0ka Jan 19, 2024
fdfd5b6
fix compute v2
k0ka Jan 19, 2024
a14ea62
Apply php-cs-fixer changes
k0ka Jan 19, 2024
d22523e
images service doc
k0ka Jan 19, 2024
fa2bcd9
unify create-service docs
k0ka Jan 20, 2024
7af31ed
upgrade object store docs
k0ka Jan 21, 2024
52df2be
Merge branch 'master' into rewrite-docs
k0ka Jan 27, 2024
8eba760
new docs for networking
k0ka Jan 30, 2024
e4fe49c
final fixes
k0ka Jan 30, 2024
6b4feae
run tests
k0ka Jan 30, 2024
c8b197e
fix test
k0ka Jan 30, 2024
2a0446c
fix test
k0ka Jan 30, 2024
82d75b5
fix tests
k0ka Jan 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions doc/_exts/osdoc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from docutils.parsers.rst import Directive
from docutils import nodes


class OsDoc(Directive):
required_arguments = 1
has_content = True

def run(self):
full_url = self.arguments[0]
title = 'official documentation'

text = []
text.extend([
nodes.Text('More information can be found in the '),
nodes.reference(title, title, internal=False, refuri=self.arguments[0]),
nodes.Text('.')
])

return [nodes.paragraph(
'',
'',
nodes.Text('More information can be found in the '),
nodes.reference(title, title, internal=False, refuri=full_url),
nodes.Text('.')
)]


def setup(app):
app.add_directive('osdoc', OsDoc)
return {'version': '0.1'}
46 changes: 27 additions & 19 deletions doc/_exts/samples.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
from docutils import nodes
from sphinx.addnodes import download_reference
from docutils.parsers.rst import directives
from sphinx.directives.code import LiteralInclude
import re

from sphinx.util.typing import OptionSpec


class Sample(LiteralInclude):
option_spec: OptionSpec = {
'full': directives.flag,
}

def run(self):
self.arguments[0] = "/../samples/" + self.arguments[0]
self.options['language'] = 'php'

def run(self):
self.arguments[0] = "/../samples/" + self.arguments[0]
self.options['language'] = 'php'
pattern = r"[\s+]?(\<\?php.*?]\);)"

pattern = r"[\s+]?(\<\?php.*?]\);)"
code_block = super(Sample, self).run()[0]
if 'full' in self.options:
return [code_block]

code_block = super(Sample, self).run()[0]
string = str(code_block[0])
string = str(code_block[0])

match = re.match(pattern, string, re.S)
if match is None:
return [code_block]
match = re.match(pattern, string, re.S)
if match is None:
return [code_block]

auth_str = match.group(1).strip()
main_str = re.sub(pattern, "", string, 0, re.S).strip()
main_str = re.sub(pattern, "", string, 0, re.S).strip()
if main_str == '':
return [code_block]

show_hide_btn = download_reference(reftarget=self.arguments[0])
return [
nodes.literal_block(main_str, main_str, language="php")
]

return [
show_hide_btn,
nodes.literal_block(auth_str, auth_str, language="php"),
nodes.literal_block(main_str, main_str, language="php")]

def setup(app):
app.add_directive('sample', Sample)
return {'version': '0.1'}
app.add_directive('sample', Sample)
return {'version': '0.1'}
4 changes: 4 additions & 0 deletions doc/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
summary {
margin-bottom: 1rem;
cursor: pointer;
}
18 changes: 18 additions & 0 deletions doc/common/create-service.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Create Service
==============

In order to work with the service you have to :doc:`setup the client </setup>` first.

Service can be created via :substitution-code:`|method|()` method of the ``OpenStack`` object.

.. code-block:: php
:substitutions:

$service = $openstack->|method|();

A list of additional options can be passed to the method. For example, to change the region:

.. code-block:: php
:substitutions:

$service = $openstack->|method|(['region' => '{region}']);
1 change: 1 addition & 0 deletions doc/common/service.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In order to work with |models| you have to :doc:`create the service <create>` first.
20 changes: 18 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@
lexers['php-annotations'] = PhpLexer(startinline=True, linenos=1)
primary_domain = 'php'

extensions = ['samples', 'refdoc', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinxcontrib.phpdomain']
extensions = [
'samples',
'refdoc',
'osdoc',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinxcontrib.phpdomain',
'sphinx_toolbox.collapse',
'sphinx_substitution_extensions',
]
source_suffix = '.rst'
master_doc = 'index'
project = u'php-opencloud'
copyright = u'2015-2023, PHP OpenCloud & contributors'
version = '1.12'
release = '1.12.1'
exclude_patterns = ['_build']
exclude_patterns = ['_build', 'common']
pygments_style = 'sphinx'

html_theme = 'sphinx_rtd_theme'
Expand All @@ -39,6 +48,13 @@
# Output file base name for HTML help builder.
htmlhelp_basename = 'php-openclouddoc'

# These folders are copied to the documentation's HTML output
html_static_path = ['_static']

html_css_files = [
'css/custom.css',
]

latex_documents = [
('index', 'php-opencloud.tex', u'php-opencloud Documentation',
u'Jamie Hannaford', 'manual'),
Expand Down
40 changes: 11 additions & 29 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,40 +1,23 @@
Welcome to the OpenStack SDK for PHP!
=====================================

Requirements
------------

* PHP >= 7, < 9
* cURL extension

Installation
------------

You must install this library through Composer:

.. code-block:: bash
About
-----

composer require php-opencloud/openstack
OpenStack SDK allows PHP developers to easily connect to OpenStack APIs in a simple and idiomatic way.
This binding is specifically designed for OpenStack APIs, but other provider SDKs are available.
Multiple OpenStack services, and versions of services, are supported.

If you do not have Composer installed, please read the `Composer installation instructions`_.

Once you have installed the SDK as a dependency of your project, you will need to load Composer’s autoloader
(which registers all the required namespaces). To do this, place the following line of PHP code at the top of your
application’s PHP files:

.. code-block:: php

require 'vendor/autoload.php';

This assumes your application's PHP files are located in the same folder as ``vendor/``. If your files are located
elsewhere, please supply the path to vendor/autoload.php in the require statement above.
.. toctree::
install
setup

Supported services
------------------

.. toctree::
:glob:
:maxdepth: 1
:maxdepth: 0

services/**/index

Expand All @@ -49,6 +32,5 @@ Contributing
If you'd like to contribute to the project, or require help running the unit/integration tests, please view the
`contributing guidelines`_.

.. _Composer installation instructions: `https://getcomposer.org/doc/00-intro.md`
.. _Github repo: `https://github.com/php-opencloud/openstack`
.. _contributing guidelines: `https://github.com/php-opencloud/openstack/blob/master/CONTRIBUTING.md`
.. _Github repo: https://github.com/php-opencloud/openstack
.. _contributing guidelines: https://github.com/php-opencloud/openstack/blob/master/CONTRIBUTING.md
35 changes: 35 additions & 0 deletions doc/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Installation
============

Requirements
------------

* PHP >= 7, < 9
* cURL extension

Install via composer
--------------------

You must install this library through Composer:

.. code-block:: bash

composer require php-opencloud/openstack

If you do not have Composer installed, please read the `Composer installation instructions`_.

Include autoloader
------------------

Once you have installed the SDK as a dependency of your project, you will need to load Composer’s autoloader
(which registers all the required namespaces). To do this, place the following line of PHP code at the top of your
application’s PHP files:

.. code-block:: php

require 'vendor/autoload.php';

This assumes your application's PHP files are located in the same folder as ``vendor/``. If your files are located
elsewhere, please supply the path to vendor/autoload.php in the require statement above.

.. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md
4 changes: 3 additions & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
sphinxcontrib-phpdomain>=0.11.0
sphinx-rtd-theme>=0.5.1
sphinx-rtd-theme>=0.5.1
sphinx-toolbox>=3.5.0
sphinx-substitution-extensions
4 changes: 2 additions & 2 deletions doc/services/block-storage/v2/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Block Storage v2

Block Storage v2 API is deprecated since Pike release and was removed in the Xena release.
It is recommended to use Block Storage v3 API instead. However most of endpoints are identical, so if you still need
to use Block Storage v2 API, you can use the change `$openstack->blockStorageV3()` to `$openstack->blockStorageV2()` in examples.
to use Block Storage v2 API, you can use the change ``$openstack->blockStorageV3()`` to ``$openstack->blockStorageV2()`` in examples.
In most cases it will work without any other changes.

.. sample:: BlockStorage/v2/create_service.php
.. sample:: BlockStorage/v2/create.php
3 changes: 3 additions & 0 deletions doc/services/block-storage/v3/create.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. |method| replace:: blockStorageV3

.. include:: /common/create-service.rst
14 changes: 10 additions & 4 deletions doc/services/block-storage/v3/index.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
Block Storage v3
================

OpenStack Block Storage API v3 (Cinder). Cinder is the OpenStack Block Storage service for providing volumes
to Nova virtual machines, Ironic bare metal hosts, containers and more.

.. osdoc:: https://docs.openstack.org/api-ref/block-storage/v3/

.. toctree::
:maxdepth: 3
:maxdepth: 3

volumes
volume-types
snapshots
create
volumes
volume-types
snapshots
18 changes: 13 additions & 5 deletions doc/services/block-storage/v3/snapshots.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
Snapshots
=========

List volumes
------------
A snapshot is read-only point in time copy of a volume. The snapshot can be created from a volume that is currently in use
or in an available state. The snapshot can then be used to create a new volume.

.. osdoc:: https://docs.openstack.org/api-ref/block-storage/v3/#volume-snapshots-snapshots

.. |models| replace:: snapshots

.. include:: /common/service.rst

List
----

.. sample:: BlockStorage/v3/snapshots/list.php
.. refdoc:: OpenStack/BlockStorage/v2/Service.html#method_listSnapshots

Each iteration will return a php:class:`Snapshot` instance <OpenStack/BlockStorage/v2/Models/Snapshot.html>.

.. include:: /common/generators.rst

List volumes sorted
~~~~~~~~~~~~~~~~~~~
List sorted
~~~~~~~~~~~

Possible values for sort_key are:

Expand Down
Loading
Loading