Moving docs to rst

Change-Id: I7f054b5afbe6021c03bbce04cce4938d5fba425c
diff --git a/Makefile b/Makefile
index 5395e58..130603c 100644
--- a/Makefile
+++ b/Makefile
@@ -51,9 +51,9 @@
 	docker run -d -p 50070:50070 -p 50060:50060 --privileged --rm --name bbsim ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} /app/bbsim ${DOCKER_RUN_ARGS}
 
 .PHONY: docs
-docs: # @HELP Generate docs and serve them in the browser
-	@echo "\033[36m Open your browser at localhost:6060 \033[0m"
-	godoc -http=localhost:6060
+docs: # @HELP Generate docs and opens them in the browser
+	pushd docs; make doc_venv; make html; popd
+	open docs/build/html/index.html
 
 # Release related items
 # Generates binaries in $RELEASE_DIR with name $RELEASE_NAME-$RELEASE_OS_ARCH
diff --git a/README.md b/README.md
index 4566a7d..8c9c657 100644
--- a/README.md
+++ b/README.md
@@ -1,147 +1,23 @@
-# BroadBand Simular (BBSim) 
+# BroadBand Simular (BBSim)
 
-## Build
+Build
+=====
 
-BBSim is managed via a `Makefile`, plese run the following command
-to display all the available targets
+BBSim is managed via a `Makefile`, plese run the following command to
+display all the available targets
 
-```
-make help
-```
+    make help
 
-## Usage
+Documentation
+=============
 
-### Deploy on Kubernets
+More advanced documentation lives in [here](./docs/index.rst).
 
-Once VOLTHA is deployed you can deploy BBsim using the helm chart provided in the repo:
-
-```
-git clone https://github.com/opencord/helm-charts.git
-helm install -n bbsim bbsim
-```
-
-### OLT Provisioning
-
-Once `BBSim` is up and running you can provision the OLT in VOLTHA.
-
-When you install the `BBSim` helm chart you'll notice that the last line of the output
-prints the service name and port:
+You can generate and browse the documentation by executing:
 
 ```bash
-...
-NOTES:
-BBSim deployed with release name: bbsim
-
-OLT ID: 0
-# of NNI Ports: 1
-# of PON Ports: 2
-# of ONU Ports: 2
-Total ONUs: (total: 4)
-
-OLT is listening on: "voltha.svc.bbsim:50060"
+make docs
 ```
 
-#### VOLTHA 1.X
-
-Connect to the voltha CLI and execute this commands:
-
-```bash
-preprovision_olt -t openolt -H voltha.svc.bbsim:50060
-enable
-```
-
-#### VOLTHA 2.X
-
-_This assumes `voltctl` is installed an configured_
-
-```bash
-voltctl device create -t openolt -H bbsim:50060
-voltctl device enable $(voltctl device list --filter Type~openolt -q)
-```
-
-## Control API
-
-BBSim comes with a gRPC interface to control the internal state.
-This interface can be queried using `bbsimctl` (the tool can be build with `make build`
-and it's available inside the `bbsim` container):
-
-```bash
-$ ./bbsimctl --help
-Usage:
-  bbsimctl [OPTIONS] <config | olt | onus>
-
-Global Options:
-  -c, --config=FILE           Location of client config file [$BBSIMCTL_CONFIG]
-  -s, --server=SERVER:PORT    IP/Host and port of XOS
-  -d, --debug                 Enable debug mode
-
-Help Options:
-  -h, --help                  Show this help message
-
-Available commands:
-  config  generate bbsimctl configuration
-  olt     OLT Commands
-  onus    List ONU Devices
-```
-
-`bbsimctl` can be configured via a config file such as:
-
-``` bash
-$ cat ~/.bbsim/config
-apiVersion: v1
-server: 127.0.0.1:50070
-grpc:
-  timeout: 10s
-```
-
-Some example commands:
-
-```bash
-$ ./bbsimctl olt get
-ID    SERIALNUMBER    OPERSTATE    INTERNALSTATE
-0     BBSIM_OLT_0     up           enabled
-
-
-$ ./bbsimctl olt pons
-PON Ports for : BBSIM_OLT_0
-
-ID    OPERSTATE
-0     up
-1     up
-2     up
-3     up
-
-
-$ ./bbsimctl onu list
-PONPORTID    ID    SERIALNUMBER    STAG    CTAG    OPERSTATE    INTERNALSTATE
-0            1     BBSM00000001    900     900     up           eap_response_identity_sent
-0            2     BBSM00000002    900     901     up           eap_start_sent
-0            3     BBSM00000003    900     902     up           auth_failed
-0            4     BBSM00000004    900     903     up           auth_failed
-1            1     BBSM00000101    900     904     up           eap_response_success_received
-1            2     BBSM00000102    900     905     up           eap_response_success_received
-1            3     BBSM00000103    900     906     up           eap_response_challenge_sent
-1            4     BBSM00000104    900     907     up           auth_failed
-2            1     BBSM00000201    900     908     up           auth_failed
-2            2     BBSM00000202    900     909     up           eap_start_sent
-2            3     BBSM00000203    900     910     up           eap_response_identity_sent
-2            4     BBSM00000204    900     911     up           eap_start_sent
-3            1     BBSM00000301    900     912     up           eap_response_identity_sent
-3            2     BBSM00000302    900     913     up           auth_failed
-3            3     BBSM00000303    900     914     up           auth_failed
-3            4     BBSM00000304    900     915     up           auth_failed
-```
-
-### Autocomplete
-
-`bbsimctl` comes with autocomplete, just run:
-
-```bash
-source <(bbsimctl completion bash)
-```
-
-## Documentation
-
-More advanced documentation lives in the [here](./docs/README.md)
-
-> This project structure is based on [golang-standards/project-layout](https://github.com/golang-standards/project-layout).
+> This project structure is based on
+> [golang-standards/project-layout](https://github.com/golang-standards/project-layout).
diff --git a/cmd/bbsim/bbsim.go b/cmd/bbsim/bbsim.go
index 2ceb50a..48b9743 100644
--- a/cmd/bbsim/bbsim.go
+++ b/cmd/bbsim/bbsim.go
@@ -1,17 +1,17 @@
 /*
- * Copyright 2018-present Open Networking Foundation
+* Copyright 2018-present Open Networking Foundation
 
- * 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
+* 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
+* 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.
+* 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.
  */
 
 package main
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644
index 0000000..2fbfb8c
--- /dev/null
+++ b/docs/.gitignore
@@ -0,0 +1,2 @@
+build
+doc_venv
\ No newline at end of file
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..379e0e2
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,25 @@
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+SOURCEDIR     = source
+BUILDDIR      = build
+
+# Put it first so that "make" without argument is like "make help".
+help:
+	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+.PHONY: help Makefile
+
+doc_venv:
+	virtualenv doc_venv ;\
+	source ./doc_venv/bin/activate ;\
+	pip install livereload ;\
+	pip install -r requirements.txt
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
+%: Makefile
+	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
diff --git a/docs/README.md b/docs/README.md
deleted file mode 100644
index 6aed37b..0000000
--- a/docs/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# BBSim Documentation
-
-- [ONU State Machine](./onu-state-machine.md)
-- [Using development dependencies](./development-dependencies.md)
-- [BBR](./bbr.md)
\ No newline at end of file
diff --git a/docs/__init__.py b/docs/__init__.py
new file mode 100644
index 0000000..f99c2ea
--- /dev/null
+++ b/docs/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2018-present Open Networking Foundation
+
+# 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.
\ No newline at end of file
diff --git a/docs/bbr.md b/docs/bbr.md
deleted file mode 100644
index 359d106..0000000
--- a/docs/bbr.md
+++ /dev/null
@@ -1,66 +0,0 @@
-# BBR
-
-BBR (a.k.a BBSim Reflector) is a tool designed to scale test BBSim.
-It is responsible to emulate ONOS and VOLTHA in order to quickly reply
-to any message that BBSim sends.
-
-Here is a graph of the measuraments of BBSim performance captured over
-10 runs with different PON Layout
-
-![BBSim Performances](./assets/bbr_runs.png "BBSim Performances") 
-
-
-## Run BBR
-
-To run `bbr` you need to have a `bbsim` instance running.
-
-You can start `bbsim` locally with:
-
-```bash
-$ DOCKER_RUN_ARGS="-onu 16 -pon 4" make docker-run
-```
-
-Once `bbsim` is up and running you'll see this on the console:
-
-```bash
-docker run -p 50070:50070 -p 50060:50060 --privileged --rm --name bbsim """"bbsim:0.0.2-dev /app/bbsim -onu 16 -pon 4
-time="2019-10-18T00:24:46Z" level=info msg="BroadBand Simulator is on" NumNniPerOlt=1 NumOnuPerPon=16 NumPonPerOlt=4 OltID=0
-time="2019-10-18T00:24:46Z" level=debug msg=CreateOLT ID=0 NumNni=1 NumOnuPerPon=16 NumPon=4 module=OLT
-time="2019-10-18T00:24:46Z" level=info msg="Successfully activated DHCP Server" module=NNI
-time="2019-10-18T00:24:46Z" level=debug msg="Created OLT with id: 0"
-time="2019-10-18T00:24:46Z" level=debug msg="Started APIService"
-time="2019-10-18T00:24:46Z" level=debug msg="APIServer Listening on: 0.0.0.0:50070"
-time="2019-10-18T00:24:46Z" level=debug msg="OLT Listening on: 0.0.0.0:50060" module=OLT
-```
-
-At this point you can start `bbr` (note that you need to pass the same number of ONUs and PON Ports to the two processes):
-
-```bash
-$ ./bbr -onu 16 -pon 4
-```
-
-`bbr` will run to completion and output the time it took to bring all the ONUs to the `dhcp_ack` state.
-If the `bbr` process doesn't exit, it means something went wrong.
-
-## Debugging and issue reporting
-
-If you are experiencing issues with `bbr` please capture:
-- `bbr` logs
-- `bbsim` logs
-- `bbsimctl onu list` output
-
-You can use these commands to capture `bbsim` and `bbr` logs during execution:
-
-```bash
-$ DOCKER_RUN_ARGS="-onu 16 -pon 4" make docker-run 2>&1 | tee bbsim.logs
-```
-
-```bash
-$ ./bbr -onu 16 -pon 4 2>&1 | tee bbr.logs
-```
-
-And this command to retrieve the list of onus in the system (run this command once `bbr` is hanging but before terminating `bbsim`):
-
-```bash
-docker exec bbsim bbsimctl onu list > onu.list
-```
\ No newline at end of file
diff --git a/docs/development-dependencies.md b/docs/development-dependencies.md
deleted file mode 100644
index fa1a474..0000000
--- a/docs/development-dependencies.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# Development dependencies
-
-To use a patched version of the `omci-sim` library:
-
-```bash
-make dep
-cd vendor/github.com/opencord/
-rm -rf omci-sim/
-git clone https://gerrit.opencord.org/omci-sim
-cd omci-sim
-```
-
-Once done, go to `gerrit.opencord.org` and locate the patch you want to get. Click on the download URL and copy the `Checkout` command.
-
-It should look something like:
-
-```
-git fetch ssh://teone@gerrit.opencord.org:29418/omci-sim refs/changes/67/15067/1 && git checkout FETCH_HEAD
-```
-
-Then just execute that command in the `omci-sim` folder inside the vendored dependencies.
\ No newline at end of file
diff --git a/docs/onu-state-machine.md b/docs/onu-state-machine.md
deleted file mode 100644
index 6155ecf..0000000
--- a/docs/onu-state-machine.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# ONU State Machine
-
-In `BBSim` the device state is createdtained using a state machine library: [fsm](https://github.com/looplab/fsm).
-
-Here is a list of possible state transitions in BBSim:
-
-|Transition|Starting States|End State| Notes |
-| --- | --- | --- | --- |
-| - | - | created |
-| discover | created | discovered |
-| enable | discovered, disabled | enabled |
-| receive_eapol_flow | enabled, gem_port_added | eapol_flow_received |
-| add_gem_port | enabled, eapol_flow_received | gem_port_added | We need to wait for both the flow and the gem port to come before moving to `auth_started` |
-| start_auth | eapol_flow_received, gem_port_added | auth_started |
-| eap_start_sent | auth_started | eap_start_sent |
-| eap_response_identity_sent | eap_start_sent | eap_response_identity_sent |
-| eap_response_challenge_sent | eap_response_identity_sent | eap_response_challenge_sent |
-| eap_response_success_received | eap_response_challenge_sent | eap_response_success_received |
-| auth_failed | auth_started, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent | auth_failed |
-| start_dhcp | eap_response_success_received | dhcp_started |
-| dhcp_discovery_sent | dhcp_started | dhcp_discovery_sent |
-| dhcp_request_sent | dhcp_discovery_sent | dhcp_request_sent |
-| dhcp_ack_received | dhcp_request_sent | dhcp_ack_received |
-| dhcp_failed | dhcp_started, dhcp_discovery_sent, dhcp_request_sent | dhcp_failed |
-
-
-In addition some transition can be forced via the API:
-
-|Transition|Starting States|End State| Notes |
-| --- | --- | --- | --- |
-| disable | eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed | disabled | Emulates a devide mulfunction. Sends a `DyingGaspInd` and then an `OnuIndication{OperState: 'down'}`|
\ No newline at end of file
diff --git a/docs/requirements.txt b/docs/requirements.txt
new file mode 100644
index 0000000..3496da1
--- /dev/null
+++ b/docs/requirements.txt
@@ -0,0 +1,14 @@
+Sphinx~=1.8.5
+actdiag~=0.5.4
+blockdiag~=1.5.4
+livereload~=2.6.1
+nwdiag~=1.0.4
+recommonmark~=0.6.0
+rstcheck~=3.3.1
+seqdiag~=0.9.6
+sphinx-reload~=0.2.0
+sphinx-rtd-theme~=0.4.3
+sphinxcontrib-actdiag~=0.8.5
+sphinxcontrib-blockdiag~=1.5.5
+sphinxcontrib-nwdiag~=0.9.5
+sphinxcontrib-seqdiag~=0.8.5
\ No newline at end of file
diff --git a/docs/source/__init__.py b/docs/source/__init__.py
new file mode 100644
index 0000000..f99c2ea
--- /dev/null
+++ b/docs/source/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2018-present Open Networking Foundation
+
+# 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.
\ No newline at end of file
diff --git a/docs/assets/bbr_runs.png b/docs/source/_static/bbr_runs.png
similarity index 100%
rename from docs/assets/bbr_runs.png
rename to docs/source/_static/bbr_runs.png
Binary files differ
diff --git a/docs/source/bbr.rst b/docs/source/bbr.rst
new file mode 100644
index 0000000..f62a3d7
--- /dev/null
+++ b/docs/source/bbr.rst
@@ -0,0 +1,75 @@
+.. _BBSim Reflector:
+
+BBSim Reflector
+===============
+
+BBR (a.k.a BBSim Reflector) is a tool designed to scale test BBSim. It
+is responsible to emulate ONOS and VOLTHA in order to quickly reply to
+any message that BBSim sends.
+
+Here is a graph of the measuraments of BBSim performance captured over
+10 runs with different PON Layout
+
+.. figure:: ./_static/bbr_runs.png
+   :alt: BBSim Performances
+
+   BBSim Performances
+
+Run BBR
+-------
+
+To run ``bbr`` you need to have a ``bbsim`` instance running.
+
+You can start ``bbsim`` locally with:
+
+.. code:: bash
+
+   $ DOCKER_RUN_ARGS="-onu 16 -pon 4" make docker-run
+
+Once ``bbsim`` is up and running you’ll see this on the console:
+
+.. code:: bash
+
+   docker run -p 50070:50070 -p 50060:50060 --privileged --rm --name bbsim """"bbsim:0.0.2-dev /app/bbsim -onu 16 -pon 4
+   time="2019-10-18T00:24:46Z" level=info msg="BroadBand Simulator is on" NumNniPerOlt=1 NumOnuPerPon=16 NumPonPerOlt=4 OltID=0
+   time="2019-10-18T00:24:46Z" level=debug msg=CreateOLT ID=0 NumNni=1 NumOnuPerPon=16 NumPon=4 module=OLT
+   time="2019-10-18T00:24:46Z" level=info msg="Successfully activated DHCP Server" module=NNI
+   time="2019-10-18T00:24:46Z" level=debug msg="Created OLT with id: 0"
+   time="2019-10-18T00:24:46Z" level=debug msg="Started APIService"
+   time="2019-10-18T00:24:46Z" level=debug msg="APIServer Listening on: 0.0.0.0:50070"
+   time="2019-10-18T00:24:46Z" level=debug msg="OLT Listening on: 0.0.0.0:50060" module=OLT
+
+At this point you can start ``bbr`` (note that you need to pass the same
+number of ONUs and PON Ports to the two processes):
+
+.. code:: bash
+
+   $ ./bbr -onu 16 -pon 4
+
+``bbr`` will run to completion and output the time it took to bring all
+the ONUs to the ``dhcp_ack`` state. If the ``bbr`` process doesn’t exit,
+it means something went wrong.
+
+Debugging and issue reporting
+-----------------------------
+
+If you are experiencing issues with ``bbr`` please capture: - ``bbr``
+logs - ``bbsim`` logs - ``bbsimctl onu list`` output
+
+You can use these commands to capture ``bbsim`` and ``bbr`` logs during
+execution:
+
+.. code:: bash
+
+   $ DOCKER_RUN_ARGS="-onu 16 -pon 4" make docker-run 2>&1 | tee bbsim.logs
+
+.. code:: bash
+
+   $ ./bbr -onu 16 -pon 4 2>&1 | tee bbr.logs
+
+And this command to retrieve the list of onus in the system (run this
+command once ``bbr`` is hanging but before terminating ``bbsim``):
+
+.. code:: bash
+
+   docker exec bbsim bbsimctl onu list > onu.list
diff --git a/docs/source/bbsimctl.rst b/docs/source/bbsimctl.rst
new file mode 100644
index 0000000..ea7b344
--- /dev/null
+++ b/docs/source/bbsimctl.rst
@@ -0,0 +1,87 @@
+.. _BBSimCtl:
+
+BBSimCtl
+========
+
+BBSim comes with a gRPC interface to control the internal state. This
+interface can be queried using `bbsimctl` (the tool can be build with
+`make build` and it's available inside the `bbsim` container):
+
+.. code:: bash
+
+    $ ./bbsimctl --help
+    Usage:
+      bbsimctl [OPTIONS] <command>
+
+    Global Options:
+      -c, --config=FILE           Location of client config file [$BBSIMCTL_CONFIG]
+      -s, --server=SERVER:PORT    IP/Host and port of XOS
+      -d, --debug                 Enable debug mode
+
+    Help Options:
+      -h, --help                  Show this help message
+
+    Available commands:
+      completion  generate shell compleition
+      config      generate bbsimctl configuration
+      log         set bbsim log level
+      olt         OLT Commands
+      onu         ONU Commands
+
+``bbsimctl`` can be configured via a config file such as:
+
+.. code:: bash
+
+    $ cat ~/.bbsim/config
+    apiVersion: v1
+    server: 127.0.0.1:50070
+    grpc:
+      timeout: 10s
+
+Example commands
+----------------
+
+.. code:: bash
+
+    $ ./bbsimctl olt get
+    ID    SERIALNUMBER    OPERSTATE    INTERNALSTATE
+    0     BBSIM_OLT_0     up           enabled
+
+
+    $ ./bbsimctl olt pons
+    PON Ports for : BBSIM_OLT_0
+
+    ID    OPERSTATE
+    0     up
+    1     up
+    2     up
+    3     up
+
+
+    $ ./bbsimctl onu list
+    PONPORTID    ID    SERIALNUMBER    STAG    CTAG    OPERSTATE    INTERNALSTATE
+    0            1     BBSM00000001    900     900     up           eap_response_identity_sent
+    0            2     BBSM00000002    900     901     up           eap_start_sent
+    0            3     BBSM00000003    900     902     up           auth_failed
+    0            4     BBSM00000004    900     903     up           auth_failed
+    1            1     BBSM00000101    900     904     up           eap_response_success_received
+    1            2     BBSM00000102    900     905     up           eap_response_success_received
+    1            3     BBSM00000103    900     906     up           eap_response_challenge_sent
+    1            4     BBSM00000104    900     907     up           auth_failed
+    2            1     BBSM00000201    900     908     up           auth_failed
+    2            2     BBSM00000202    900     909     up           eap_start_sent
+    2            3     BBSM00000203    900     910     up           eap_response_identity_sent
+    2            4     BBSM00000204    900     911     up           eap_start_sent
+    3            1     BBSM00000301    900     912     up           eap_response_identity_sent
+    3            2     BBSM00000302    900     913     up           auth_failed
+    3            3     BBSM00000303    900     914     up           auth_failed
+    3            4     BBSM00000304    900     915     up           auth_failed
+
+Autocomplete
+------------
+
+``bbsimctl`` comes with autocomplete, just run:
+
+.. code:: bash
+
+    source <(bbsimctl completion bash)
diff --git a/docs/source/conf.py b/docs/source/conf.py
new file mode 100644
index 0000000..0a9ac82
--- /dev/null
+++ b/docs/source/conf.py
@@ -0,0 +1,188 @@
+# Copyright 2018-present Open Networking Foundation
+
+# 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.
+
+# -*- coding: utf-8 -*-
+#
+# Configuration file for the Sphinx documentation builder.
+#
+# This file does only contain a selection of the most common options. For a
+# full list see the documentation:
+# http://www.sphinx-doc.org/en/master/config
+
+# -- Path setup --------------------------------------------------------------
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#
+# import os
+# import sys
+# sys.path.insert(0, os.path.abspath('.'))
+
+
+# -- Project information -----------------------------------------------------
+
+project = u'BBSim'
+copyright = u'2019, Open Networking Foundation'
+author = u'Open Networking Foundation'
+
+# The short X.Y version
+version = u''
+# The full version, including alpha/beta/rc tags
+release = u''
+
+
+# -- General configuration ---------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#
+# needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+    'sphinx.ext.graphviz'
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+#
+# source_suffix = ['.rst', '.md']
+source_suffix = '.rst'
+
+# The master toctree document.
+master_doc = 'index'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = None
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This pattern also affects html_static_path and html_extra_path.
+exclude_patterns = []
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = None
+
+
+# -- Options for HTML output -------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+#
+html_theme = 'alabaster'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#
+# html_theme_options = {}
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Custom sidebar templates, must be a dictionary that maps document names
+# to template names.
+#
+# The default sidebars (for documents that don't match any pattern) are
+# defined by theme itself.  Builtin themes are using these templates by
+# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
+# 'searchbox.html']``.
+#
+# html_sidebars = {}
+
+
+# -- Options for HTMLHelp output ---------------------------------------------
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'BBSimdoc'
+
+
+# -- Options for LaTeX output ------------------------------------------------
+
+latex_elements = {
+    # The paper size ('letterpaper' or 'a4paper').
+    #
+    # 'papersize': 'letterpaper',
+
+    # The font size ('10pt', '11pt' or '12pt').
+    #
+    # 'pointsize': '10pt',
+
+    # Additional stuff for the LaTeX preamble.
+    #
+    # 'preamble': '',
+
+    # Latex figure (float) alignment
+    #
+    # 'figure_align': 'htbp',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+#  author, documentclass [howto, manual, or own class]).
+latex_documents = [
+    (master_doc, 'BBSim.tex', u'BBSim Documentation',
+     u'Open Networking Foundation', 'manual'),
+]
+
+
+# -- Options for manual page output ------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    (master_doc, 'bbsim', u'BBSim Documentation',
+     [author], 1)
+]
+
+
+# -- Options for Texinfo output ----------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+    (master_doc, 'BBSim', u'BBSim Documentation',
+     author, 'BBSim', 'One line description of project.',
+     'Miscellaneous'),
+]
+
+
+# -- Options for Epub output -------------------------------------------------
+
+# Bibliographic Dublin Core info.
+epub_title = project
+
+# The unique identifier of the text. This can be a ISBN number
+# or the project homepage.
+#
+# epub_identifier = ''
+
+# A unique identification for the text.
+#
+# epub_uid = ''
+
+# A list of files that should not be packed into the epub file.
+epub_exclude_files = ['search.html']
diff --git a/docs/source/development-dependencies.rst b/docs/source/development-dependencies.rst
new file mode 100644
index 0000000..0a5e2ac
--- /dev/null
+++ b/docs/source/development-dependencies.rst
@@ -0,0 +1,26 @@
+.. _Development dependencies:
+
+Development dependencies
+========================
+
+To use a patched version of the ``omci-sim`` library:
+
+.. code:: bash
+
+   make dep
+   cd vendor/github.com/opencord/
+   rm -rf omci-sim/
+   git clone https://gerrit.opencord.org/omci-sim
+   cd omci-sim
+
+Once done, go to ``gerrit.opencord.org`` and locate the patch you want
+to get. Click on the download URL and copy the ``Checkout`` command.
+
+It should look something like:
+
+::
+
+   git fetch ssh://teone@gerrit.opencord.org:29418/omci-sim refs/changes/67/15067/1 && git checkout FETCH_HEAD
+
+Then just execute that command in the ``omci-sim`` folder inside the
+vendored dependencies.
diff --git a/docs/source/index.rst b/docs/source/index.rst
new file mode 100644
index 0000000..5aabec3
--- /dev/null
+++ b/docs/source/index.rst
@@ -0,0 +1,67 @@
+.. BBSim documentation master file, created by
+   sphinx-quickstart on Fri Oct 25 12:03:42 2019.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to BBSim's documentation!
+=================================
+
+.. toctree::
+   :maxdepth: 2
+   :caption: Contents:
+
+   onu-state-machine.rst
+   development-dependencies.rst
+   bbr.rst
+   bbsimctl.rst
+
+
+Quickstart
+----------
+
+BBSim (a.k.a. BroadBand Simulator) is a tool designed to emulate an `Openolt <https://github.com/opencord/openolt>`_
+compatible device.
+
+In order to use BBSim you need to have:
+
+- a Kubernetes cluster
+- helm
+- a working installation of VOLTHA
+
+We strongly recommend the utilization of `kind-voltha <https://github.com/ciena/kind-voltha>`_ to setup such environment.
+
+Installation
+------------
+
+Once VOLTHA is up and running, you can deploy BBSim with this command:
+
+.. code:: bash
+
+    helm install -n bbsim cord/bbsim
+
+The BBSim installation can be customized to emulate multiple ONUs and multiple PON Ports:
+
+.. code:: bash
+
+    helm install -n bbsim cord/bbsim --set onu=8 --set pon=2
+
+Once BBSim is installed you can verify that it's running with:
+
+.. code:: bash
+
+    kubectl logs -n voltha -f $(kubectl get pods -n voltha | grep bbsim | awk '{print $1}')
+
+Provision a BBSim OLT in VOLTHA
+-------------------------------
+
+Create the device:
+
+.. code:: bash
+
+    voltctl device create -t openolt -H $(kubectl get -n voltha service/bbsim -o go-template='{{.spec.clusterIP}}'):50060
+
+Enable the device:
+
+.. code:: bash
+
+    voltctl device enable $(voltctl device list --filter Type~openolt -q)
diff --git a/docs/source/onu-state-machine.rst b/docs/source/onu-state-machine.rst
new file mode 100644
index 0000000..9df3ca6
--- /dev/null
+++ b/docs/source/onu-state-machine.rst
@@ -0,0 +1,113 @@
+.. _ONU State Machine:
+
+ONU State Machine
+=================
+
+In ``BBSim`` the device state is createdtained using a state machine
+library: `fsm <https://github.com/looplab/fsm>`__.
+
+Here is a list of possible state transitions in BBSim:
+
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| Transition                     | Starting States                                                                        | End State                      | Notes                                                                                         |
++================================+========================================================================================+================================+===============================================================================================+
+|                                |                                                                                        | created                        |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| discover                       | created                                                                                | discovered                     |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| enable                         | discovered, disabled                                                                   | enabled                        |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| receive_eapol_flow             | enabled, gem_port_added                                                                | eapol_flow_received            |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| add_gem_port                   | enabled, eapol_flow_received                                                           | gem_port_added                 | We need to wait for both the flow and the gem port to come before moving to ``auth_started``  |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| start_auth                     | eapol_flow_received, gem_port_added                                                    | auth_started                   |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| eap_start_sent                 | auth_started                                                                           | eap_start_sent                 |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| eap_response_identity_sent     | eap_start_sent                                                                         | eap_response_identity_sent     |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| eap_response_challenge_sent    | eap_response_identity_sent                                                             | eap_response_challenge_sent    |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| eap_response_success_received  | eap_response_challenge_sent                                                            | eap_response_success_received  |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| auth_failed                    | auth_started, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent  | auth_failed                    |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| start_dhcp                     | eap_response_success_received                                                          | dhcp_started                   |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| dhcp_discovery_sent            | dhcp_started                                                                           | dhcp_discovery_sent            |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| dhcp_request_sent              | dhcp_discovery_sent                                                                    | dhcp_request_sent              |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| dhcp_ack_received              | dhcp_request_sent                                                                      | dhcp_ack_received              |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+| dhcp_failed                    | dhcp_started, dhcp_discovery_sent, dhcp_request_sent                                   | dhcp_failed                    |                                                                                               |
++--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
+
+In addition some transition can be forced via the API:
+
++---------------------+----------------------------------------------------------------------------+-----------+---------------------------------------------------------------------------------------------------------+
+| End StateTransition | Starting States                                                            | End State | Notes                                                                                                   |
++=====================+============================================================================+===========+=========================================================================================================+
+| disable             | eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed | disabled  | Emulates a devide mulfunction. Sends a ``DyingGaspInd`` and then an ``OnuIndication{OperState: 'down'}``|
++---------------------+----------------------------------------------------------------------------+-----------+---------------------------------------------------------------------------------------------------------+
+
+Below is a diagram of the state machine:
+
+- In blue PON related states
+- In green EAPOL related states
+- In yellow DHCP related states
+- In purple operator driven states
+
+..
+  TODO Evaluate http://blockdiag.com/en/seqdiag/examples.html
+
+.. graphviz::
+
+    digraph {
+        graph [pad="1,1" bgcolor="#cccccc"]
+        node [style=filled]
+
+        created [fillcolor="#bee7fa"]
+        discovered [fillcolor="#bee7fa"]
+        enabled [fillcolor="#bee7fa"]
+        disabled [fillcolor="#f9d6ff"]
+        gem_port_added [fillcolor="#bee7fa"]
+
+        eapol_flow_received [fillcolor="#e6ffc2"]
+        auth_started [fillcolor="#e6ffc2"]
+        eap_start_sent [fillcolor="#e6ffc2"]
+        eap_response_identity_sent [fillcolor="#e6ffc2"]
+        eap_response_challenge_sent [fillcolor="#e6ffc2"]
+        eap_response_success_received [fillcolor="#e6ffc2"]
+        auth_failed [fillcolor="#e6ffc2"]
+
+        dhcp_started [fillcolor="#fffacc"]
+        dhcp_discovery_sent [fillcolor="#fffacc"]
+        dhcp_request_sent [fillcolor="#fffacc"]
+        dhcp_ack_received [fillcolor="#fffacc"]
+        dhcp_failed [fillcolor="#fffacc"]
+
+        created -> discovered -> enabled
+        enabled -> gem_port_added -> eapol_flow_received -> auth_started
+        enabled -> eapol_flow_received -> gem_port_added -> auth_started
+
+        auth_started -> eap_start_sent -> eap_response_identity_sent -> eap_response_challenge_sent -> eap_response_success_received
+        auth_started -> auth_failed
+        eap_start_sent -> auth_failed
+        eap_response_identity_sent -> auth_failed
+        eap_response_challenge_sent -> auth_failed
+
+        eap_response_success_received -> dhcp_started
+        dhcp_started -> dhcp_discovery_sent -> dhcp_request_sent -> dhcp_ack_received
+        dhcp_started -> dhcp_failed
+        dhcp_discovery_sent -> dhcp_failed
+        dhcp_request_sent -> dhcp_failed
+        dhcp_ack_received dhcp_failed
+
+        eap_response_success_received -> disabled
+        auth_failed -> disabled
+        dhcp_ack_received -> disabled
+        dhcp_failed -> disabled
+        disabled -> enabled
+    }
\ No newline at end of file