capella2polarion.documents package

A package containing document generation related modules.

Submodules

capella2polarion.documents.document_config module

Module with classes and a loader for document rendering configs.

class capella2polarion.documents.document_config.BaseDocumentRenderingConfig(*, template_directory: str | ~pathlib.Path, project_id: str | None = None, text_work_item_type: str = 'text', text_work_item_id_field: str = '__C2P__id', status_allow_list: list[str] | None = None, heading_numbering: bool = False, work_item_layouts: dict[str, ~capella2polarion.documents.document_config.WorkItemLayout] = <factory>, instances: ~collections.abc.Sequence[~capella2polarion.documents.document_config.DocumentRenderingInstance])

Bases: BaseModel

A template config, which can result in multiple Polarion documents.

heading_numbering: bool
instances: Sequence[DocumentRenderingInstance]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

project_id: str | None
status_allow_list: list[str] | None
template_directory: str | Path
text_work_item_id_field: str
text_work_item_type: str
work_item_layouts: dict[str, WorkItemLayout]
class capella2polarion.documents.document_config.DocumentConfigs(*, full_authority: list[FullAuthorityDocumentRenderingConfig] = <factory>, mixed_authority: list[MixedAuthorityDocumentRenderingConfig] = <factory>)

Bases: BaseModel

The overall document configuration repository.

full_authority: list[FullAuthorityDocumentRenderingConfig]
iterate_documents() Iterator[DocumentInfo]

Yield all document paths of the config as tuples.

mixed_authority: list[MixedAuthorityDocumentRenderingConfig]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class capella2polarion.documents.document_config.DocumentRenderingInstance(*, polarion_type: str | None = None, polarion_space: str, polarion_name: str, polarion_title: str | None = None, params: dict[str, ~typing.Any]=<factory>)

Bases: BaseModel

An instance of a document that should be created in Polarion.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

params: dict[str, Any]
polarion_name: str
polarion_space: str
polarion_title: str | None
polarion_type: str | None
class capella2polarion.documents.document_config.FullAuthorityDocumentRenderingConfig(*, template_directory: str | ~pathlib.Path, project_id: str | None = None, text_work_item_type: str = 'text', text_work_item_id_field: str = '__C2P__id', status_allow_list: list[str] | None = None, heading_numbering: bool = False, work_item_layouts: dict[str, ~capella2polarion.documents.document_config.WorkItemLayout] = <factory>, instances: ~collections.abc.Sequence[~capella2polarion.documents.document_config.DocumentRenderingInstance], template: str)

Bases: BaseDocumentRenderingConfig

Full authority document config with one template per document.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

template: str
class capella2polarion.documents.document_config.MixedAuthorityDocumentRenderingConfig(*, template_directory: str | ~pathlib.Path, project_id: str | None = None, text_work_item_type: str = 'text', text_work_item_id_field: str = '__C2P__id', status_allow_list: list[str] | None = None, heading_numbering: bool = False, work_item_layouts: dict[str, ~capella2polarion.documents.document_config.WorkItemLayout] = <factory>, instances: ~collections.abc.Sequence[~capella2polarion.documents.document_config.SectionBasedDocumentRenderingInstance], sections: dict[str, str])

Bases: BaseDocumentRenderingConfig

Mixed authority document with multiple auto generated sections.

instances: Sequence[SectionBasedDocumentRenderingInstance]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

sections: dict[str, str]
class capella2polarion.documents.document_config.SectionBasedDocumentRenderingInstance(*, polarion_type: str | None = None, polarion_space: str, polarion_name: str, polarion_title: str | None = None, params: dict[str, ~typing.Any]=<factory>, section_params: dict[str, dict[str, ~typing.Any]]=<factory>)

Bases: DocumentRenderingInstance

An instance of a mixed authority doc with section specific params.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

section_params: dict[str, dict[str, Any]]
class capella2polarion.documents.document_config.WorkItemLayout(*, show_description: bool = True, show_title: bool = True, show_fields_as_table: bool = True, fields_at_start: list[str] = <factory>, fields_at_end: list[str] = <factory>)

Bases: BaseModel

Configuration for rendering layouts of work items.

fields_at_end: list[str]
fields_at_start: list[str]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

show_description: bool
show_fields_as_table: bool
show_title: bool
capella2polarion.documents.document_config.generate_work_item_layouts(configs: dict[str, WorkItemLayout]) list[RenderingLayout]

Create polarion_api.RenderingLayouts for a given configuration.

capella2polarion.documents.document_config.read_config_file(config: TextIO, model: MelodyModel | None = None) DocumentConfigs

Read a yaml containing a list of DocumentRenderingConfigs.

capella2polarion.documents.document_renderer module

A capella2polarion-specific adapter over Polarion’s generic renderer.

capella2polarion.documents.document_renderer.AREA_END_CLS = 'c2pAreaEnd'

This class is expected for a div in a wiki macro to end a rendering area in mixed authority documents.

capella2polarion.documents.document_renderer.AREA_START_CLS = 'c2pAreaStart'

This class is expected for a div in a wiki macro to start a rendering area in mixed authority documents.

class capella2polarion.documents.document_renderer.DocumentRenderer(polarion_repository: PolarionDataRepository, model: MelodyModel, model_work_item_project_id: str)

Bases: DocumentRenderer

Render documents using the shared Polarion API client renderer.

get_template_context() dict[str, Any]

Return model as additional template context.

resolve_work_item(obj: object, work_item_id: str | None = None) tuple[str | None, WorkItem | None]

Resolve Capella elements; delegate all other inputs to base.

capella2polarion.documents.mass_document_renderer module

Provides functionalities to render multiple documents config based.

class capella2polarion.documents.mass_document_renderer.MassDocumentRenderer(polarion_repository: PolarionDataRepository, model: MelodyModel, model_work_item_project_id: str, overwrite_heading_numbering: bool = False, overwrite_layouts: bool = False)

Bases: object

A class to render multiple documents based on configs.

render_documents(configs: DocumentConfigs, existing_documents: dict[tuple[str | None, str, str], tuple[Document | None, list[WorkItem]]]) dict[str | None, ProjectData]

Render all documents defined in the given config.

Returns:

A dict mapping project ID to new and updated documents.

Return type:

documents

class capella2polarion.documents.mass_document_renderer.ProjectData(new_docs: list[DocumentData] = <factory>, updated_docs: list[DocumentData] = <factory>)

Bases: object

A class holding data of a project which documents are rendered for.

new_docs: list[DocumentData]
updated_docs: list[DocumentData]