Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix structure in sphinx and download duplicated doc files from gallery #569

Merged
merged 2 commits into from Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Expand Up @@ -124,3 +124,10 @@ pyfar/signals/files/*
# workaround for failing test discovery in vscode
tests/*/__init__.py
tests/private/

# ignore downloads from pyfar gallery
docs/header.rst
docs/_static/favicon.ico
docs/_static/header.rst
docs/_static/css/custom.css
docs/resources/logos/pyfar_logos_fixed_size_pyfar.png
8 changes: 0 additions & 8 deletions docs/_static/css/custom.css

This file was deleted.

Binary file removed docs/_static/favicon.ico
Binary file not shown.
41 changes: 0 additions & 41 deletions docs/_templates/navbar-nav.html

This file was deleted.

32 changes: 32 additions & 0 deletions docs/conf.py
Expand Up @@ -8,6 +8,8 @@

import os
import sys
import urllib3
import shutil
sys.path.insert(0, os.path.abspath('..'))

import pyfar # noqa
Expand All @@ -26,6 +28,7 @@
'autodocsumm',
'sphinx_design',
'sphinx_favicon',
'sphinx_reredirects',
]

# show tocs for classes and functions of modules using the autodocsumm
Expand Down Expand Up @@ -107,6 +110,7 @@
"navbar_start": ["navbar-logo"],
"navbar_end": ["navbar-icon-links", "theme-switcher"],
"navbar_align": "content",
"header_links_before_dropdown": 8,
"icon_links": [
{
"name": "GitHub",
Expand All @@ -125,6 +129,34 @@
"default_mode": "light"
}

# redirect index to pyfar.html
redirects = {
"index": "pyfar.html"
}

# -- download navbar and style files from gallery -----------------------------
branch = 'main'
link = f'https://github.com/pyfar/gallery/raw/{branch}/docs/'
folders_in = [
'_static/css/custom.css',
'_static/favicon.ico',
'_static/header.rst',
'resources/logos/pyfar_logos_fixed_size_pyfar.png'
]
c = urllib3.PoolManager()
for file in folders_in:
url = link + file
filename = file
os.makedirs(os.path.dirname(filename), exist_ok=True)
with c.request('GET', url, preload_content=False) as res, open(filename, 'wb') as out_file:
shutil.copyfileobj(res, out_file)

# replace pyfar hard link to internal link
with open("_static/header.rst", "rt") as fin:
with open("header.rst", "wt") as fout:
for line in fin:
fout.write(line.replace(f'https://{project}.readthedocs.io', project))

# -- pyfar specifics -----------------------------------------------------

# write shortcuts to sphinx readable format
Expand Down
52 changes: 1 addition & 51 deletions docs/index.rst
@@ -1,52 +1,2 @@
.. |pyfar_logo| image:: resources/pyfar.png
:width: 150
:alt: Alternative text

Getting Started
===============

.. toctree::
:maxdepth: 2

readme

Documentation
=============

.. toctree::
:maxdepth: 2

concepts

.. toctree::
:maxdepth: 2

classes

.. toctree::
:maxdepth: 2

modules

Contributing
===============

.. toctree::
:maxdepth: 1

contributing

Other
=====
.. toctree::
:maxdepth: 1

history

..
(removed because it is contained in the new spinx style)
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. include:: header.rst
31 changes: 31 additions & 0 deletions docs/pyfar.rst
@@ -0,0 +1,31 @@
pyfar
=====

.. toctree::
:caption: Getting Started
:maxdepth: 2

readme


.. toctree::
:caption: Documentation
:maxdepth: 2

concepts
classes
modules


.. toctree::
:caption: Contributing
:maxdepth: 1

contributing


.. toctree::
:caption: Other
:maxdepth: 1

history
Binary file not shown.
Binary file removed docs/resources/pyfar.png
Binary file not shown.
1 change: 1 addition & 0 deletions requirements_dev.txt
Expand Up @@ -20,3 +20,4 @@ sofar>=1.1.1
pydata-sphinx-theme
sphinx-design
sphinx-favicon
sphinx-reredirects