Skip to content

Commit ca6e353

Browse files
committed
Improve documentation
1 parent f02a824 commit ca6e353

10 files changed

+199
-108
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository contains a client library and a few handy utilities for easy access to all of the capabilities of B2 Cloud Storage.
44

5-
[B2 command-line tool](https://github.com/Backblaze/B2_Command_Line_Tool) is an exampl of how it can be used to provide command-line access to the B2 service, but there are many possible applications (including FUSE filesystems, storage backend drivers for backup applications etc).
5+
[B2 command-line tool](https://github.com/Backblaze/B2_Command_Line_Tool) is an example of how it can be used to provide command-line access to the B2 service, but there are many possible applications (including FUSE filesystems, storage backend drivers for backup applications etc).
66

77
# Installation
88

doc/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ help:
1414

1515
.PHONY: help Makefile
1616

17+
.PHONY: clean
18+
clean:
19+
rm -rf $(BUILDDIR)/*
20+
1721
# Catch-all target: route all unknown targets to Sphinx using the new
1822
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1923
%: Makefile

doc/source/api_reference.rst

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
########################
2+
API Reference
3+
########################
4+
5+
.. toctree::
6+
authentication
7+
source_dest
8+
b2sdk/api
9+
b2sdk/bucket
10+
b2sdk/cache
11+
b2sdk/exception
12+
b2sdk/file_version
13+
b2sdk/progress
14+
b2sdk/utils
15+
sync

doc/source/authentication.rst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
########################
2+
Authentication
3+
########################
4+
5+
.. toctree::
6+
7+
b2sdk/account_info/abstract
8+
b2sdk/account_info/exception
9+
b2sdk/account_info/sqlite_account_info
10+
b2sdk/account_info/upload_url_pool

doc/source/intro/tutorial.rst renamed to doc/source/examples.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
========
2-
Tutorial
2+
Examples
33
========
44

55
Account authorization
@@ -72,3 +72,4 @@ Account information
7272
===================
7373

7474
TODO
75+

doc/source/index.rst

+8-94
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,22 @@
1-
=========================================
2-
Welcome to B2 Python SDK's documentation!
3-
=========================================
4-
1+
#########################################
52
Overview
6-
========
3+
#########################################
74

85
B2 SDK is a client library for easy access to all of the capabilities of B2 Cloud Storage.
96

10-
B2 command-line tool (https://github.com/Backblaze/B2_Command_Line_Tool) is an example of how it can be used
7+
`B2 command-line tool <https://github.com/Backblaze/B2_Command_Line_Tool>`_ is an example of how it can be used
118
to provide command-line access to the B2 service, but there are many possible applications
129
(including FUSE filesystems, storage backend drivers for backup applications etc).
1310

14-
First steps
15-
===========
16-
17-
.. toctree::
18-
:caption: First Steps
19-
:hidden:
20-
21-
intro/install
22-
intro/tutorial
23-
24-
:doc:`intro/install`
25-
Get B2 SDK installed on your computer
26-
27-
:doc:`intro/tutorial`
28-
A quick tutorial on how to get started with B2 SDK
29-
30-
API Reference
31-
=============
32-
3311
.. toctree::
34-
:caption: API Reference
35-
:hidden:
36-
37-
b2sdk/api
38-
b2sdk/bucket
39-
b2sdk/cache
40-
b2sdk/download_dest
41-
b2sdk/exception
42-
b2sdk/file_version
43-
b2sdk/progress
44-
b2sdk/upload_source
45-
b2sdk/utils
46-
b2sdk/account_info/abstract
47-
b2sdk/account_info/exception
48-
b2sdk/account_info/sqlite_account_info
49-
b2sdk/account_info/upload_url_pool
50-
b2sdk/sync/action
51-
b2sdk/sync/exception
52-
b2sdk/sync/file
53-
b2sdk/sync/folder_parser
54-
b2sdk/sync/folder
55-
b2sdk/sync/policy_manager
56-
b2sdk/sync/policy
57-
b2sdk/sync/scan_policies
58-
b2sdk/sync/sync
59-
60-
:doc:`b2sdk/api`
61-
62-
:doc:`b2sdk/bucket`
63-
64-
:doc:`b2sdk/cache`
65-
66-
:doc:`b2sdk/download_dest`
67-
68-
:doc:`b2sdk/exception`
69-
70-
:doc:`b2sdk/file_version`
71-
72-
:doc:`b2sdk/progress`
73-
74-
:doc:`b2sdk/upload_source`
75-
76-
:doc:`b2sdk/utils`
77-
78-
:doc:`b2sdk/account_info/abstract`
79-
80-
:doc:`b2sdk/account_info/exception`
81-
82-
:doc:`b2sdk/account_info/sqlite_account_info`
83-
84-
:doc:`b2sdk/account_info/upload_url_pool`
85-
86-
:doc:`b2sdk/sync/action`
87-
88-
:doc:`b2sdk/sync/exception`
89-
90-
:doc:`b2sdk/sync/file`
91-
92-
:doc:`b2sdk/sync/folder_parser`
93-
94-
:doc:`b2sdk/sync/folder`
95-
96-
:doc:`b2sdk/sync/policy_manager`
97-
98-
:doc:`b2sdk/sync/policy`
99-
100-
:doc:`b2sdk/sync/scan_policies`
10112

102-
:doc:`b2sdk/sync/sync`
13+
install
14+
user_guide
15+
api_reference
10316

17+
#########################################
10418
Indices and tables
105-
==================
19+
#########################################
10620

10721
* :ref:`genindex`
10822
* :ref:`modindex`
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
1-
==================
1+
########################
22
Installation Guide
3-
==================
3+
########################
44

55
Installing B2 SDK
66
=================
77

8+
Safety first
9+
~~~~~~~~~~~~~~~
10+
11+
.. caution:: Correct version pinning is necessary to make sure your code remains compatible with upcoming b2sdk releases.
12+
13+
See :ref:`this <semver>` chapter for details.
14+
15+
Installing for development
16+
~~~~~~~~~~~~~~~~~~~~~~~~~~
17+
818
B2 SDK runs on Python 2.7+ under CPython and PyPy.
919

10-
To install B2 SDK run::
20+
To install B2 SDK, simply run::
1121

1222
pip install b2sdk
1323

14-
If you see a message saying that the `six` library cannot be installed, which
15-
happens if you're installing with the system python on OS X El Capitan, try
16-
this::
24+
In your python environment.
25+
26+
.. note:: If you see a message saying that the ``six`` library cannot be installed, which
27+
happens if you're installing with the system python on OS X El Capitan, try this::
28+
29+
pip install --ignore-installed b2sdk
1730

18-
pip install --ignore-installed b2sdk
1931

2032
Developer Info
2133
==============
@@ -27,7 +39,7 @@ We encourage outside contributors to perform changes on our codebase. Many such
2739
* maintain a set of integration tests (run with a production cloud)
2840
* maintain a set of (well over a hundred) unit tests
2941
* automatically run unit tests on 14 versions of python (including osx, Jython and pypy)
30-
* format the code automatically using [yapf](https://github.com/google/yapf)
42+
* format the code automatically using `yapf <https://github.com/google/yapf>`_
3143
* use static code analysis to find subtle/potential issues with maintainability
3244
* maintain other Continous Integration tools (coverage tracker)
3345

@@ -42,17 +54,17 @@ There is a `Makefile` with a rule to run the unit tests using the currently acti
4254

4355
will install the required packages, then run the unit tests.
4456

45-
To test in multiple python virtual environments, set the enviroment variable `PYTHON_VIRTUAL_ENVS`
57+
To test in multiple python virtual environments, set the enviroment variable ``PYTHON_VIRTUAL_ENVS``
4658
to be a space-separated list of their root directories. When set, the makefile will run the
4759
unit tests in each of the environments.
4860

49-
Before checking in, use the `pre-commit.sh` script to check code formatting, run
61+
Before checking in, use the ``pre-commit.sh`` script to check code formatting, run
5062
unit tests, run integration tests etc.
5163

52-
The integration tests need a file in your home directory called `.b2_auth`
64+
The integration tests need a file in your home directory called ``.b2_auth``
5365
that contains two lines with nothing on them but your account ID and application key::
5466

5567
accountId
5668
applicationKey
5769

58-
We marked the places in the code which are significantly less intuitive than others in a special way. To find them occurrences, use `git grep '*magic*'`.
70+
We marked the places in the code which are significantly less intuitive than others in a special way. To find them occurrences, use ``git grep '*magic*'``.

doc/source/source_dest.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
########################
2+
Sources and Destinations
3+
########################
4+
5+
.. toctree::
6+
7+
b2sdk/download_dest
8+
b2sdk/upload_source

doc/source/sync.rst

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
########################
2+
Sync
3+
########################
4+
5+
.. toctree::
6+
7+
b2sdk/sync/action
8+
b2sdk/sync/exception
9+
b2sdk/sync/file
10+
b2sdk/sync/folder_parser
11+
b2sdk/sync/folder
12+
b2sdk/sync/policy_manager
13+
b2sdk/sync/policy
14+
b2sdk/sync/scan_policies
15+
b2sdk/sync/sync

doc/source/user_guide.rst

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
##########
2+
User guide
3+
##########
4+
5+
.. _semver:
6+
7+
***************************************
8+
Version pinning
9+
***************************************
10+
11+
b2sdk is divided into three parts. Please pay attention to which group you use, as the stability of your application depends on correct pinning of versions.
12+
13+
++++++++++
14+
Interfaces
15+
++++++++++
16+
17+
Public
18+
======
19+
20+
Public interface consists of *public* members of the following modules:
21+
22+
.. autosummary::
23+
:nosignatures:
24+
25+
b2sdk.api.B2Api
26+
b2sdk.bucket.Bucket
27+
b2sdk.exception
28+
b2sdk.sync
29+
b2sdk.sync.exception
30+
b2sdk.account_info.abstract
31+
b2sdk.account_info.exception
32+
b2sdk.account_info.sqlite_account_info
33+
b2sdk.account_info.upload_url_pool
34+
b2sdk.transferer
35+
b2sdk.utils
36+
37+
Those will not change in a backwards-incompatible way between non-major versions. In other words, if you pin your dependencies to `>=x.0.0;<x+1.0.0`, everything should be ok.
38+
In other words, if you pin your dependencies to
39+
40+
.. hint:: If the current version of b2sdk is 4.5.6 and you only use the public interfaces, put this in your requirements.txt::
41+
42+
>=4.5.6;<5.0.0
43+
44+
.. note:: b2sdk.*._something and b2sdk.*.*._something, having a name which begins with an underscore, are NOT considred public interface.
45+
46+
47+
Protected
48+
=========
49+
50+
Things which sometimes might be necssary to use that are NOT considered public interface (and may change in a non-major version):
51+
52+
.. autosummary::
53+
:nosignatures:
54+
55+
b2sdk.session.B2Session
56+
b2sdk.raw_api.B2RawApi
57+
b2sdk.b2http.B2Http
58+
59+
.. note:: it is ok for you to use those (better that, than copying our sources), however if you do, please pin your dependencies to middle version.
60+
61+
.. hint:: If the current version of b2sdk is 4.5.6 and you use the public and protected interfaces, put this in your requirements.txt::
62+
63+
>=4.5.6;<4.6.0
64+
65+
66+
Private
67+
=======
68+
69+
If you need to use some of our private interfaces, pin your dependencies strictly.
70+
71+
.. hint:: If the current version of b2sdk is 4.5.6 and you use the private interface, put this in your requirements.txt::
72+
73+
==4.5.6
74+
75+
*************
76+
Authorization
77+
*************
78+
79+
Before you can use b2sdk, you need to prove who you are to the server. For that you will need to pass `account id` and `api token` to one of the authorization classes.
80+
81+
In case you are storing that information in a database or something, you can implement your own class by inheriting from AbstractAuthorization. Otherwise, use one of the classes included in b2sdk package:
82+
83+
84+
InMemoryAccountInfo:
85+
86+
This is probably what your application should be using and also what we use in our tests.
87+
88+
89+
SqliteAccountInfo:
90+
91+
this is what B2 CLI uses to authorize the user. Stores information in a local file.
92+
93+
94+
B2Api
95+
~~~~~
96+
97+
The "main" object that abstracts the communication with B2 cloud is B2Api. It lets you manage buckets and download files by id.
98+
99+
example
100+
101+
102+
Bucket
103+
~~~~~~
104+
105+
Bucket class abstracts the B2 bucket, which is essentially a namespace for objects.
106+
107+
The best way to transfer your files into a bucket and back, is to use *sync*.
108+
109+
If for some reason you cannot use sync, it is also possible to upload and download files directly into/from the bucket, using Bucket.upload_file and Bucket.download_by_name.
110+
111+
The Bucket object also contains a few methods to list the contents of the bucket and the metadata associated with the objects contained in it.
112+

0 commit comments

Comments
 (0)