Skip to content

Commit

Permalink
PropertyTree documentation cleanup, change intersphinx python to poin…
Browse files Browse the repository at this point in the history
…t at 3.6
  • Loading branch information
julianneswinoga committed Jan 3, 2024
1 parent 541909b commit 5556f77
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/source/conf.py
Expand Up @@ -19,7 +19,8 @@
autosummary_generate = True

intersphinx_mapping = {
'python': ('http://docs.python.org/3', None),
'python': ('https://docs.python.org/3.6', None),
'requests': ('https://requests.readthedocs.io/en/latest/', None),
}

templates_path = ['_templates']
Expand Down
24 changes: 23 additions & 1 deletion flightgear_python/fg_if.py
Expand Up @@ -187,6 +187,10 @@ def __init__(self, gui_version: int):


class PropertyTreeValue(NamedTuple):
"""
Internal representation for working with values from the property tree
sphinx-no-autodoc
"""
absolute_path: str
value_str: str
type_str: str
Expand Down Expand Up @@ -216,6 +220,10 @@ def _auto_convert_fg_prop(value_str: str, type_str: str) -> Any:

@staticmethod
def check_and_normalize_prop_path(path: str) -> str:
"""
Make sure the path is always absolute and strip trailing slashes
sphinx-no-autodoc
"""
if not path.startswith('/'):
raise ValueError(f'Path must be absolute (start with /): {path}')
path = path.rstrip('/') if path != "/" else path # Strip trailing slash to keep things consistent
Expand Down Expand Up @@ -396,6 +404,10 @@ def set_prop(self, prop_str: str, value: Any):
# We don't care about the response

def get_values_and_dirs(self, path: str) -> Tuple[List[PropertyTreeValue], List[str]]:
"""
Internal method to populate a shared property tree data structure
sphinx-no-autodoc
"""
resp_list = self._send_cmd_get_resp(f'ls {path}').split('\r\n')
val_list: List[PropertyTreeValue] = []
dir_list: List[str] = []
Expand Down Expand Up @@ -434,7 +446,13 @@ def __init__(self, host: str, tcp_port: int, timeout_s: float = 2.0):
self.timeout_s = timeout_s

def request_shim(self, method: str, url: str, *args, **kwargs) -> requests.Response:
# Shim layer over session.request so we can set default options and handle errors in a unified fashion
"""
Shim layer over session.request so we can set default options and handle errors in a unified fashion
sphinx-no-autodoc
:param method: Directly copied from :meth:`requests.Session.request()`
:param url: Directly copied from :meth:`requests.Session.request()`
"""
try:
return self.session.request(method, url, *args, timeout=self.timeout_s, **kwargs)
except requests.exceptions.ConnectionError:
Expand Down Expand Up @@ -475,6 +493,10 @@ def set_prop(self, prop_str: str, value: Any):
# We don't care about the response

def get_values_and_dirs(self, path: str) -> Tuple[List[PropertyTreeValue], List[str]]:
"""
Internal method to populate a shared property tree data structure
sphinx-no-autodoc
"""
resp_json = self.request_shim('GET', self.url + path).json()
if resp_json['nChildren'] == 0:
return [], []
Expand Down
4 changes: 4 additions & 0 deletions flightgear_python/general_util.py
Expand Up @@ -71,6 +71,10 @@ def strip_end(text: Union[str, ByteString], suffix: Union[str, ByteString]) -> U


def deprecate_rename_wrapper(old_obj: object, old_fn: str, new_obj: object, new_fn: str):
"""
Small wrapper function to soft-rename objects
sphinx-no-autodoc
"""
def new_fn_with_warning(*args, **kwargs):
# Turn on warnings after the old name has been used
warnings.simplefilter('default')
Expand Down

0 comments on commit 5556f77

Please sign in to comment.