From 9d71aaf223655c7926fe0f4e284231110fb4cc7e Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Thu, 18 Jul 2024 18:48:05 +0100 Subject: [PATCH] better docstrings and ruff fixes --- fastkml/registry.py | 1 + fastkml/styles.py | 343 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 341 insertions(+), 3 deletions(-) diff --git a/fastkml/registry.py b/fastkml/registry.py index b341a6d6..d80aaff0 100644 --- a/fastkml/registry.py +++ b/fastkml/registry.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +"""Registry for XML objects.""" from dataclasses import dataclass from enum import Enum from typing import TYPE_CHECKING diff --git a/fastkml/styles.py b/fastkml/styles.py index e0e745ee..5f311898 100644 --- a/fastkml/styles.py +++ b/fastkml/styles.py @@ -15,6 +15,8 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """ +KML Styles. + Once you've created features within Google Earth and examined the KML code Google Earth generates, you'll notice how styles are an important part of how your data is displayed. @@ -82,6 +84,29 @@ def __init__( url: Optional[str] = None, **kwargs: Any, ) -> None: + """ + Initialize a Style object. + + Args: + ---- + ns : str, optional + The namespace of the Style object. + name_spaces : dict, optional + A dictionary of namespace prefixes and their corresponding URIs. + id : str, optional + The ID of the Style object. + target_id : str, optional + The ID of the target object that this Style object applies to. + url : str, optional + The URL of the Style object. + **kwargs : Any + Additional keyword arguments. + + Returns: + ------- + None + + """ super().__init__( ns=ns, name_spaces=name_spaces, @@ -105,6 +130,15 @@ def __repr__(self) -> str: ) def __bool__(self) -> bool: + """ + Check if the style has a URL. + + Returns + ------- + bool + True if the style has a URL, False otherwise. + + """ return bool(self.url) @classmethod @@ -128,7 +162,8 @@ def get_tag_name(cls) -> str: class _StyleSelector(_BaseObject): """ - This is an abstract element and cannot be used directly in a KML file. + Abstract element that cannot be used directly in a KML file. + It is the base type for the