diff --git a/tangostationcontrol/docs/docs-requirements.txt b/tangostationcontrol/docs/docs-requirements.txt
index 3a910678911865bf529d594c626ee1d8c2c5860e..756ea268af967fb9f45107517758b85cd15fc1b6 100644
--- a/tangostationcontrol/docs/docs-requirements.txt
+++ b/tangostationcontrol/docs/docs-requirements.txt
@@ -1,3 +1,4 @@
 importlib-metadata<2.0.0,>=0.12;python_version<"3.8"
 sphinx>=4.3.2 # BSD
-sphinx-rtd-theme>=1.0.0 # MIT
\ No newline at end of file
+sphinx-rtd-theme>=1.0.0 # MIT
+sphinxcontrib-apidoc>=0.3.0 #BSD
diff --git a/tangostationcontrol/docs/source/conf.py b/tangostationcontrol/docs/source/conf.py
index f1cd59b63a2fdc92f7f2840dd4c12d9a6f83e24a..696055140472823b16528aafe74b9036a9e84009 100644
--- a/tangostationcontrol/docs/source/conf.py
+++ b/tangostationcontrol/docs/source/conf.py
@@ -27,7 +27,22 @@ author = "Stichting ASTRON"
 # 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"]
+extensions = [
+    "sphinx.ext.graphviz",
+    "sphinx.ext.autodoc",
+    "sphinx.ext.viewcode",
+    "sphinxcontrib.apidoc",
+]
+
+apidoc_module_dir = "../../tangostationcontrol"
+apidoc_output_dir = "source_documentation"
+apidoc_excluded_paths = []
+apidoc_separate_modules = True
+apidoc_toc_file = False
+# This should include private methods but does not work
+# https://github.com/sphinx-contrib/apidoc/issues/14
+apidoc_extra_args = ["--private"]
+
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ["_templates"]
diff --git a/tangostationcontrol/docs/source/developer.rst b/tangostationcontrol/docs/source/developer.rst
index d3a725740cd81b61c7ac5eb2998934d148047c70..35df2820f0920c77b21f3c8f630ceee81024b107 100644
--- a/tangostationcontrol/docs/source/developer.rst
+++ b/tangostationcontrol/docs/source/developer.rst
@@ -3,6 +3,11 @@ Developer information
 
 This chapter describes key areas useful for developers.
 
+.. toctree::
+   :maxdepth: 2
+
+   source_documentation/index
+
 Docker compose
 -------------------------
 
diff --git a/tangostationcontrol/docs/source/source_documentation/index.rst b/tangostationcontrol/docs/source/source_documentation/index.rst
new file mode 100644
index 0000000000000000000000000000000000000000..7770d6cb32a78892131e60012ffe8c38e1f2d542
--- /dev/null
+++ b/tangostationcontrol/docs/source/source_documentation/index.rst
@@ -0,0 +1,7 @@
+Source code documentation
+=========================
+
+.. toctree::
+   :maxdepth: 3
+
+   tangostationcontrol
diff --git a/tangostationcontrol/tangostationcontrol/toolkit/udp_simulator.py b/tangostationcontrol/tangostationcontrol/toolkit/udp_simulator.py
index a7d41001cce7f21cccfae00e91d7b285a5de0f1b..26488aaf7aca9df7dd875c22209c238956aa578c 100644
--- a/tangostationcontrol/tangostationcontrol/toolkit/udp_simulator.py
+++ b/tangostationcontrol/tangostationcontrol/toolkit/udp_simulator.py
@@ -15,10 +15,11 @@ print(f"UDP target port: {UDP_PORT}")
 
 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # create UDP socket
 
-while True:
-    sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT))
-    i += 1
-    MESSAGE = "{}".format(i)
+if __name__ == "__main__":
+    while True:
+        sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT))
+        i += 1
+        MESSAGE = "{}".format(i)
 
-    # sleep for an arbitrary amount of time. Currently 0.2 settings for visual testing.
-    time.sleep(0.2)
+        # sleep for an arbitrary amount of time. Currently 0.2 settings for visual testing.
+        time.sleep(0.2)