Types

Types representing the documents structure.

class swift_rst_docs.Accessibility(*values)

A symbol’s accessibility attribute.

FILEPRIVATE = 'source.lang.swift.accessibility.fileprivate'

Restricted to the source file.

INTERNAL = 'source.lang.swift.accessibility.internal'

Restricted to the module.

OPEN = 'source.lang.swift.accessibility.open'

Open for inheritance.

PRIVATE = 'source.lang.swift.accessibility.private'

Restricted to the containing declaration.

PUBLIC = 'source.lang.swift.accessibility.public'

Accessible from another module.

UNKNOWN = 'unknown'

Unknown accessibility.

property order: int

Order of accessibility. Higher value means more accessible.

Return type:

int

class swift_rst_docs.AnnotatedDeclaration(declaration: str)

A type annotated declaration, initialized from an XML string.

chunks: list[Annotation]

The typed chunks of the declaration.

parsed: str

The full parsed declaration as plain text.

class swift_rst_docs.Annotation(chunk: str, usr: str | None)

An annotated part of a declaration.

chunk: str

The chunk of code in the declaration.

usr: str | None

An optional type USR value the chunk corresponds to.

class swift_rst_docs.DeclarationKind(*values)

A kind of declaration.

CLASS = 'source.lang.swift.decl.class'

A class.

CLASS_METHOD = 'source.lang.swift.decl.function.method.class'

A class method.

CLASS_VARIABLE = 'source.lang.swift.decl.var.class'

A class variable.

ENUM = 'source.lang.swift.decl.enum'

An enumeration.

ENUM_ELEMENT = 'source.lang.swift.decl.enumelement'

An enumeration case.

EXTENSION = 'source.lang.swift.decl.extension'

An extension.

FUNCTION = 'source.lang.swift.decl.function.free'

A global function.

INSTANCE_METHOD = 'source.lang.swift.decl.function.method.instance'

An instance method.

INSTANCE_VARIABLE = 'source.lang.swift.decl.var.instance'

An instance variable.

LOCAL_VARIABLE = 'source.lang.swift.decl.var.local'

A local variable.

PROTOCOL = 'source.lang.swift.decl.protocol'

A protocol.

STATIC_METHOD = 'source.lang.swift.decl.function.method.static'

A static method.

STATIC_VARIABLE = 'source.lang.swift.decl.var.static'

A static variable.

STRUCT = 'source.lang.swift.decl.struct'

A structure.

UNKNOWN = 'unknown'

An unknown declaration.

class swift_rst_docs.Documentation(body: str, context: GenerationContext)

The documentation of a symbol, initialized from an XML string.

comment: str

The first line of the comment string.

discussion: str | None

The rest of the comment string.

name: str

The relative name of the symbol.

parameters: list[dict[str, str]]

A list of parameters witht their documentation. Each value has name and a description key.

result: str | None

The description of the return value.

usr: str

The unique identifier of the symbol. Corresponds to its page file name (without the extension) by replacing “:” with “:”.

class swift_rst_docs.MARK(body: dict)

A mark (MARK: -) comment in the source file. Used to separate symbols into categories.

name: str

Name of the section.

class swift_rst_docs.MainPage(context: GenerationContext)

The main index page of the whole documentation. This is the same as the module index page when there is only one module.

class swift_rst_docs.ModulePage(name: str, context: GenerationContext, title: bool = True, declaration: bool = True, members: list[str] | None = None)

The index page for a module.

declaration: bool

Whether to include the module’s declaration.

members: list[str] | None

Member names (without the module) to include in the module page. If None, all members will be included.

name: str

The module name.

title: bool

Whether to include the document’s title.

class swift_rst_docs.Page(item: Symbol, context: GenerationContext)

A Swift documentation page in RST format.

Initializing from a swift_rst_docs.Symbol and a swift_rst_docs.GenerationContext automatically generates the contents. swift_rst_docs.fetch_documents() should have been called for links to be correctly generated.

contents: str

The contents of the generated page.

file_name: str

File name with extension.

class swift_rst_docs.Structure(body: dict)

A structure in the document. Initialized from a dictionary decoded from the documentation JSON file.

name: str

The name of the structure. Corresponds to the key.name key of the body passed to the initializer.

class swift_rst_docs.Symbol(body: dict, context: GenerationContext)

A source code symbol.

accessibility: Accessibility

Symbol’s accessibility level.

context: GenerationContext

The generation context fetching this symbol.

declaration: AnnotatedDeclaration

Type annotated declaration.

documentation: Documentation | None

An optional documentation attached to the symbol.

inherited_types: list[str] | None

Types the symbol inherits from.

kind: DeclarationKind

Kind of declaration.

module_name: str

The name of the module exporting this symbol.

name: str

Relative name of the symbol.

substructure: list[Structure]

Sub-declarations of the symbol.

usr: str | None

The unique identifier of the symbol. Corresponds to its page file name (without the extension) by replacing “:” with “:”.