From 9ce68f0114806d2823be2eb35389bbc1e0a59f15 Mon Sep 17 00:00:00 2001 From: Omar Aljarrah <50204418+OmarAlJarrah@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:47:30 +0300 Subject: [PATCH] chore(docs-generator): Add `gfm` formatters. (#257) PR: https://github.com/ExpediaGroup/expediagroup-python-sdk/pull/257 --- .github/workflows/generate-sdk.yaml | 15 +++++++++++++++ expediagroup/sdk/docsgen/templates/class.jinja2 | 4 ++-- requirements-docs.txt | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-sdk.yaml b/.github/workflows/generate-sdk.yaml index 02c4ee08..9148dc9f 100644 --- a/.github/workflows/generate-sdk.yaml +++ b/.github/workflows/generate-sdk.yaml @@ -58,6 +58,21 @@ jobs: cp "../generator/package/expediagroup/sdk/$namespace/model.py" "./temp/expediagroup/sdk/$namespace/model.py" python3 ./__main__.py -p ./temp -n "$namespace" + - name: Install Pandoc + run: | + pip3 install lastversion + + architecture="$(dpkg --print-architecture)" + lastversion --assets --filter "$architecture.deb" download https://github.com/jgm/pandoc + + sudo dpkg -i "$(ls | grep 'pandoc-.*\.deb')" + - name: Format docs + working-directory: expediagroup/sdk/docsgen/docs + run: | + source ../env/bin/activate + npx prettier --write --parser markdown *.md + for file in *.md; do pandoc "$file" -f markdown -t gfm -o "${file%.md}.md"; done + mdformat . - uses: actions/upload-artifact@v3 with: name: sdk diff --git a/expediagroup/sdk/docsgen/templates/class.jinja2 b/expediagroup/sdk/docsgen/templates/class.jinja2 index d54fd2cd..5f2803bd 100644 --- a/expediagroup/sdk/docsgen/templates/class.jinja2 +++ b/expediagroup/sdk/docsgen/templates/class.jinja2 @@ -1,6 +1,6 @@ {{ breadcrumbs }} # class `{{ module.name }}.{{ class.name }}` -``` +```python {{ class.constructor.name }}({% for arg in class.constructor.arguments %} {{ arg.name }}: {{ arg.datatype }},{% endfor %} ) @@ -29,7 +29,7 @@ ## Methods {% for method in class.methods %} ### {{ method.name }} -``` +```python {{ method.name }}( {% for arg in method.arguments %}{{ arg.name }}: {{ arg.datatype }}, {% endfor %}) diff --git a/requirements-docs.txt b/requirements-docs.txt index 05c49f00..308c4024 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -5,3 +5,8 @@ typer docstring_parser jinja2 mdformat-gfm~=0.3.5 +mdformat-frontmatter~=2.0.1 +mdformat-footnote~=0.1.1 +mdformat-black~=0.1.1 +mdformat-tables~=0.4.1 +mdformat_deflist~=0.1.2