Skip to content

Commit

Permalink
fix readthedocs build
Browse files Browse the repository at this point in the history
  • Loading branch information
bakatrouble committed Feb 19, 2019
1 parent 4cefda2 commit 09fc4ce
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import os
import sys
sys.path.insert(0, os.path.abspath('../src'))
sys.path.insert(0, os.path.abspath('..'))

# Import after sys.path.insert() to avoid issues
from tgvoip import __version__
import docs.mock

# -- Project information -----------------------------------------------------

Expand Down
41 changes: 41 additions & 0 deletions docs/mock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import sys
from unittest.mock import MagicMock


class _TGVoIP(MagicMock):
@classmethod
def __getattr__(cls, name):
if name in ['Stats', 'Endpoint']:
return getattr(_TGVoIP, name)
elif name in ['__loader__', '__file__']:
return None

return MagicMock()

class Stats:
"""
Object storing call stats
Attributes:
bytes_sent_wifi (``int``): Amount of data sent over WiFi
bytes_sent_mobile (``int``): Amount of data sent over mobile network
bytes_recvd_wifi (``int``): Amount of data received over WiFi
bytes_recvd_mobile (``int``): Amount of data received over mobile network
"""
pass

class Endpoint:
"""
Object storing endpoint info
Args:
_id (``int``): Endpoint ID
ip (``str``): Endpoint IPv4 address
ipv6 (``str``): Endpoint IPv6 address
port (``int``): Endpoint port
peer_tag (``bytes``): Endpoint peer tag
"""
pass


sys.modules.update(_tgvoip=_TGVoIP())
21 changes: 2 additions & 19 deletions src/_tgvoip_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,7 @@ PYBIND11_MODULE(_tgvoip, m) {
.value("PROXY", CallError::ERROR_PROXY)
.export_values();

py::class_<Stats>(m, "Stats", R"doc(
An object storing call stats
Attributes:
bytes_sent_wifi (``int``): Amount of data sent over WiFi
bytes_sent_mobile (``int``): Amount of data sent over mobile network
bytes_recvd_wifi (``int``): Amount of data received over WiFi
bytes_recvd_mobile (``int``): Amount of data received over mobile network
)doc")
py::class_<Stats>(m, "Stats")
.def_readonly("bytes_sent_wifi", &Stats::bytes_sent_wifi)
.def_readonly("bytes_sent_mobile", &Stats::bytes_sent_mobile)
.def_readonly("bytes_recvd_wifi", &Stats::bytes_recvd_wifi)
Expand All @@ -95,16 +87,7 @@ PYBIND11_MODULE(_tgvoip, m) {
return repr.str();
});

py::class_<Endpoint>(m, "Endpoint", R"doc(
An object storing endpoint info
Args:
_id (``int``): Endpoint ID
ip (``str``): Endpoint IPv4 address
ipv6 (``str``): Endpoint IPv6 address
port (``int``): Endpoint port
peer_tag (``bytes``): Endpoint peer tag
)doc")
py::class_<Endpoint>(m, "Endpoint")
.def(py::init<long, const std::string &, const std::string &, int, const std::string &>())
.def_readwrite("_id", &Endpoint::id)
.def_readwrite("ip", &Endpoint::ip)
Expand Down

0 comments on commit 09fc4ce

Please sign in to comment.