mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
[css] Add some docstrings following "did you mean" PR feedback
This commit is contained in:
@@ -119,6 +119,11 @@ class StylesBuilder:
|
||||
"""
|
||||
Returns the list of CSS properties we can manage -
|
||||
i.e. the ones for which we have a `process_[property name]` method
|
||||
|
||||
Returns:
|
||||
Sequence[str]: All the "Python-ised" CSS property names this class can handle.
|
||||
|
||||
Example: ("width", "background", "offset_x", ...)
|
||||
"""
|
||||
return [attr[8:] for attr in dir(self) if attr.startswith("process_")]
|
||||
|
||||
@@ -751,6 +756,13 @@ class StylesBuilder:
|
||||
"""
|
||||
Returns a valid CSS property "Python" name, or None if no close matches could be found.
|
||||
|
||||
Args:
|
||||
rule_name (str): An invalid "Python-ised" CSS property (i.e. "offst_x" rather than "offst-x")
|
||||
|
||||
Returns:
|
||||
str | None: The closest valid "Python-ised" CSS property.
|
||||
Returns `None` if no close matches could be found.
|
||||
|
||||
Example: returns "background" for rule_name "bkgrund", "offset_x" for "ofset_x"
|
||||
"""
|
||||
return get_suggestion(rule_name, self._get_processable_rule_names())
|
||||
|
||||
@@ -6,7 +6,14 @@ from typing import Sequence
|
||||
|
||||
def get_suggestion(word: str, possible_words: Sequence[str]) -> str | None:
|
||||
"""
|
||||
Returns a close match of 'word' amongst 'possible_words', or None if no close matches could be found.
|
||||
Returns a close match of `word` amongst `possible_words`.
|
||||
|
||||
Args:
|
||||
word (str): The word we want to find a close match for
|
||||
possible_words (Sequence[str]): The words amongst which we want to find a close match
|
||||
|
||||
Returns:
|
||||
str | None: The closest match amongst the `possible_words`. Returns `None` if no close matches could be found.
|
||||
|
||||
Example: returns "red" for word "redu" and possible words ("yellow", "red")
|
||||
"""
|
||||
@@ -16,8 +23,15 @@ def get_suggestion(word: str, possible_words: Sequence[str]) -> str | None:
|
||||
|
||||
def get_suggestions(word: str, possible_words: Sequence[str], count: int) -> list[str]:
|
||||
"""
|
||||
Returns a list of up to 'count' matches of 'word' amongst 'possible_words' -
|
||||
or an empty list if no close matches could be found.
|
||||
Returns a list of up to `count` matches of `word` amongst `possible_words`.
|
||||
|
||||
Args:
|
||||
word (str): The word we want to find a close match for
|
||||
possible_words (Sequence[str]): The words amongst which we want to find close matches
|
||||
|
||||
Returns:
|
||||
list[str]: The closest matches amongst the `possible_words`, from the closest to the least close.
|
||||
Returns an empty list if no close matches could be found.
|
||||
|
||||
Example: returns ["yellow", "ellow"] for word "yllow" and possible words ("yellow", "red", "ellow")
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user