AbsaOSS / AbsaOSS/living-doc-generator-mdoc
Exporter factory after introducing more regimes
- Lingua principale
- Python
- Stelle
- 3
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
## Background
Currently, we have [exporter_factory.py](https://github.com/AbsaOSS/living-doc-generator/pull/83/files/3e9cb177543b94d81f10ab6bcf2dee4712c08dce#diff-d655a54b312f1d732a906441b6f73ee9f0e4d0481d0fd5d8cb4f5778b864b3a2) for creating exporters.
In the future, we will have more exporters and more regimes, which could lead to a really messy match. I would propose to change this after we have multiple regimes/exporters.
## Feature
Pick a better solution for creating a specific exporter for a specific regime. We can, for example, use visitor pattern.
## Proposed Solution
This is a visitor solution it should be used only if we have multiple exporters and regimes.
```
class Regime(ABC):
@abstractmethod
def accept(self, visitor: ExporterVisitor) -> None:
pass
class living_doc_regime(Regime):
def accept(self, visitor: ExporterVisitor) -> None:
visitor.visit_living_doc_regime(self)
# implementation
class guide_regime(Regime):
def accept(self, visitor: ExporterVisitor) -> None:
visitor.visit_guide_regime(self)
# implementation
class ExporterVisitor(ABC):
@abstractmethod
def visit_living_doc_regime(self, regime: RegimeA) -> None:
pass
@abstractmethod
def visit_guide_regime(self, regime: RegimeB) -> None:
pass
class MdocExporter(ExporterVisitor):
def visit_living_doc_regime(self, regime: RegimeA) -> None:
# impl
def visit_guide_regime(self, regime: RegimeB) -> None:
# impl
class PdfExporter(ExporterVisitor):
def visit_living_doc_regime(self, regime: RegimeA) -> None:
# impl
def visit_guide_regime(self, regime: RegimeB) -> None:
# impl
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.