From d1eb38d9a1737b022f5541075ad91de67260e245 Mon Sep 17 00:00:00 2001 From: andrewgsavage Date: Sun, 1 Dec 2024 13:07:22 +0000 Subject: [PATCH] add doctest to CI (#259) --- .github/workflows/docs.yml | 50 ++++++++++++++++++++++++++++++++++++++ .readthedocs.yaml | 2 +- docs/index.rst | 4 +-- docs/user/common.rst | 3 ++- docs/user/reading.rst | 5 +++- requirements_docs.txt | 4 +-- 6 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..8ebea5e --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,50 @@ +name: Documentation Build + +on: [push, pull_request] + +jobs: + docbuild: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 100 + + - name: Get tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + + - name: Set up minimal Python version + uses: actions/setup-python@v2 + with: + python-version: "3.10" + + - name: Get pip cache dir + id: pip-cache + run: echo "::set-output name=dir::$(pip cache dir)" + + - name: Setup pip cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: pip-docs + restore-keys: pip-docs + + - name: Install locales + run: | + sudo apt-get install language-pack-fr + sudo localedef -i fr_FR -f UTF-8 fr_FR + + - name: Install dependencies + run: | + sudo apt install -y pandoc + pip install --upgrade pip setuptools wheel + pip install -r "requirements_docs.txt" + pip install docutils==0.14 commonmark==0.8.1 recommonmark==0.5.0 babel==2.8 + pip install . + + - name: Build documentation + run: sphinx-build -n -j auto -b html -d build/doctrees docs build/html + + - name: Doc Tests + run: sphinx-build -a -j auto -b doctest -d build/doctrees docs build/doctest diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 7d72db2..3d017fa 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -2,7 +2,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.9" + python: "3.11" sphinx: configuration: docs/conf.py fail_on_warning: false diff --git a/docs/index.rst b/docs/index.rst index 56a0d54..1e168f7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -68,15 +68,13 @@ Pint-pandas: Unit support for pandas User Guide Advanced topics ecosystem - API Reference .. toctree:: :maxdepth: 1 :hidden: :caption: For developers - dev/contributing - dev/pint-convert + dev/contributing .. toctree:: :maxdepth: 1 diff --git a/docs/user/common.rst b/docs/user/common.rst index 9212346..bf21821 100644 --- a/docs/user/common.rst +++ b/docs/user/common.rst @@ -59,7 +59,8 @@ The default operation of Pandas `pd.concat` function is to perform row-wise conc .. ipython:: python :suppress: - :okwarning: + :okexcept: + df = pd.concat(list_of_series, axis=1) diff --git a/docs/user/reading.rst b/docs/user/reading.rst index 93a57f5..25bada4 100644 --- a/docs/user/reading.rst +++ b/docs/user/reading.rst @@ -40,7 +40,10 @@ Let's read that into a DataFrame. Here io.StringIO is used in place of reading a df = pd.read_csv(io.StringIO(test_data), header=[0, 1], index_col=[0, 1]).T # df = pd.read_csv("/path/to/test_data.csv", header=[0, 1]) for col in df.columns: - df[col] = pd.to_numeric(df[col], errors="ignore") + try: + df[col] = pd.to_numeric(df[col]) + except ValueError: + pass df.dtypes diff --git a/requirements_docs.txt b/requirements_docs.txt index 8f44109..c8ae06e 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -1,4 +1,4 @@ -sphinx>4 +sphinx>=6 ipython<=8.12 matplotlib mip>=1.13 @@ -16,7 +16,7 @@ dask[complete] setuptools>=41.2 Serialize pygments>=2.4 -sphinx-book-theme==0.3.3 +sphinx-book-theme>=1.1.0 sphinx_copybutton sphinx_design typing_extensions