xiaohongshu
xiaohongshu
mdf-majo
meadow Docstring Format (MDF) specification for Python documentation. Use when writing, editing, or reviewing docstrings for Python code. Provides a plaintext-first, readable format that closely follows Python syntax. Trigger when the user mentions docstrings, Python documentation, function docum...
Full skill instructions
Standardize Python docstring formatting to be plaintext-first, readable, and closely aligned with Python syntax. MDF provides an intuitive documentation style that works across editors while maintaining clarity and consistency.
Use this skill when:
writing-docs-majo instead)writing-docs-majo)attributes, arguments, or parameters for incoming datafunctions or methods for outgoing APIsT | None instead of Optional[T], even for older Python versions| union syntax)A plaintext-first alternative documentation string style for Python.
MDF docstrings are composed of sections in a specific order:
| Section | Required | Position | Purpose |
|---|---|---|---|
| preamble | Yes | Start | One-line description |
| body | No | Start or End | Longer explanation |
| attributes/arguments/parameters | If applicable | Middle | Incoming signatures |
| functions/methods | If applicable | Middle | Outgoing signatures |
| returns | If not None | Middle | Return type with description |
| raises | If applicable | Middle | Exceptions |
| usage | No | Start or End | Code example |
A mandatory short one-line description:
"""a baker's confectionery, usually baked, a lie"""
A longer, potentially multi-line description:
"""a baker's confectionery, usually baked, a lie
this is a longer description that explains more about cakes
and why they might be lies in certain contexts.
"""
For classes: attributes
For functions: arguments or parameters
General format:
{attributes,arguments,parameters}:
`<python variable declaration syntax>`
<description>
Example:
"""
attributes:
`name: str`
name of the cake
`ingredients: list[Ingredient]`
ingredients of the cake
`baking_temperature: int = 4000`
temperature in degrees kelvin
"""
For modules: functions
For classes: methods
General format:
{functions,methods}:
`<python function declaration syntax without trailing colon>`
<description of the function>
Example:
"""
methods:
`def bake(self, override: BakingOverride | None = None) -> bool`
bakes the cake and returns True if successful
"""
Single type format:
{returns,raises}: `<return type annotation>`
<description>
Multiple types format:
{returns,raises}:
`<first possible return type annotation/exception class>`
<description>
`<second possible return type annotation/exception class>`
<description>
Example:
def certain_unsafe_div(a: int | float, b: int | float) -> float:
"""divide a by b
arguments:
`a: int | float`
numerator
`b: int | float`
denominator
raises:
`ZeroDivisionError`
raised when denominator is 0
`OverflowError`
raised when the resulting number is too big
returns: `float`
the result, a divided by b
"""
return a / b
A markdown triple backtick block with usage examples:
"""
usage:
```python
cake = Cake(name="Chocolate", ingredients=[...])
result = cake.bake()
```
"""
Use modern Python syntax in docstrings, even if the codebase targets older versions:
# Always use
optional_argument: T | None = None
# Not
optional_argument: Optional[T] = None
Reference third-party classes in full for attributes, but use short names in method signatures:
class ThirdPartyExample(Exception):
"""blah blah
attributes:
`field_day: external.ExternalClass`
blah blah
methods:
`def __init__(self, field_day: ExternalClass) -> None: ...`
blah blah
"""
For overloaded functions, use variable declaration syntax that makes sense:
@overload
def get_field(self) -> object: ...
@overload
def get_field(self, default: DefaultT) -> Union[object, DefaultT]: ...
def get_field(self, default: object = None) -> object:
"""...
arguments:
`default: object | None = None`
...
returns: `object`
"""
Split long declarations across multiple lines within the same indentation:
methods:
`def woah_many_argument_function(
...
) -> None`
blah blah blah blah blah blah
Simple exception hierarchies or marker classes:
class TomlanticException(Exception):
"""base exception class for all tomlantic errors"""
pass
When the return is self-explanatory from the preamble:
def difference_between_document(self, incoming_document: TOMLDocument) -> Difference:
"""returns a `tomlantic.Difference` namedtuple object of the incoming and
outgoing fields that were changed between the model and the comparison document
arguments:
`incoming_document: tomlkit.TOMLDocument`
returns: `tomlantic.Difference`
"""
class Result(NamedTuple, Generic[ResultType]):
"""typing.NamedTuple representing a result for safe value retrieval
attributes:
`value: ResultType`
value to return or fallback value if erroneous
`error: BaseException | None = None`
exception if any
methods:
`def __bool__(self) -> bool: ...`
boolean comparison for truthiness-based exception safety
`def get(self) -> ResultType: ...`
method that raises or returns an error if the Result is erroneous
`def cry(self, string: bool = False) -> str: ...`
method that returns the result value or raises an error
"""
value: ResultType
error: BaseException | None = None
def __bool__(self) -> bool:
"""boolean comparison for truthiness-based exception safety
returns: `bool`
that returns True if `self.error` is not None
"""
...
def cry(self, string: bool = False) -> str:
"""raises or returns an error if the Result is erroneous
arguments:
`string: bool = False`
if `self.error` is an Exception, returns it as a string error message
returns: `str`
returns `self.error` if it is a string, or returns an empty string if
`self.error` is None
"""
...
def get(self) -> ResultType:
"""returns the result value or raises an error
returns: `ResultType`
returns `self.value` if `self.error` is None
raises: `BaseException`
if `self.error` is not None
"""
...
class ModelBoundTOML(Generic[M]):
"""glue class for pydantic models and tomlkit documents
attributes:
`model: BaseModel`
methods:
`def __init__(self, model: type[M], document: TOMLDocument, handle_errors: bool = True) -> None: ...`
instantiates the class with a `pydantic.BaseModel` and a `tomlkit.TOMLDocument`
`def model_dump_toml(self) -> TOMLDocument: ...`
dumps the model as a style-preserved `tomlkit.TOMLDocument`
`def get_field(self, location: str | Sequence[str], default: object | None = None) -> object | None: ...`
safely retrieve a field by it's location
`def set_field(self, location: str | Sequence[str], value: object) -> None: ...`
sets a field by it's location
`def from_another_model_bound_toml(cls, model_bound_toml: ModelBoundToml[M]) -> "ModelBoundToml": ...`
classmethod that fully initialises from the data from another ModelBoundToml
usage:
```py
# instantiate the class
toml = ModelBoundTOML(YourModel, tomlkit.parse(...))
# access your model with .model
toml.model.message = "blowy red vixens fight for a quick jump"
# dump the model back to a toml document
toml_document = toml.model_dump_toml()
# or to a toml string
toml_string = toml.model_dump_toml().as_string()
```
"""
def set_field(
self,
location: Union[str, tuple[str, ...]],
value: object,
handle_errors: bool = True,
) -> None:
"""sets a field by it's location.
not recommended for general use due to a lack of type safety, but useful when
setting fields programatically
will handle `pydantic.ValidationError` into more toml-friendly error messages.
set `handle_errors` to `False` to raise the original `pydantic.ValidationError`
arguments:
`location: Union[str, tuple[str, ...]]`
dot-separated location of the field to set
`value: object`
value to set at the specified location
`handle_errors: bool = True`
whether to convert pydantic ValidationErrors to tomlantic errors
raises:
`AttributeError`
if the field does not exist
`tomlantic.TOMLValidationError`
if the document does not validate with the model
`pydantic.ValidationError`
if the document does not validate with the model and `handle_errors` is `False`
"""
...
| Section | Syntax |
|---|---|
| preamble | Plain text (first line) |
| body | Plain text |
| attributes/arguments/parameters | `name: Type` + description |
| functions/methods | `def name(...) -> Return` + description |
| returns | `ReturnType` + description |
| raises | `ExceptionClass` + description |
| usage | Code block with example |
Key rule: Always use backticks around Python code in docstrings.
This skill is standalone but commonly used with:
python-majo — Python development standardsmdf-md-api-docs-majo — MDF-style API reference documentation in markdownwriting-docs-majo — Documentation writing standardsxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience