Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykironde committed Sep 28, 2024
1 parent 5e3dd24 commit 01ab259
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 142 deletions.
191 changes: 53 additions & 138 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,107 +7,83 @@

from recommonmark.parser import CommonMarkParser
from recommonmark.transform import AutoStructify

from sphinx.highlighting import lexers
from pygments.lexers.python import PythonLexer
from deepforest._version import __version__

lexers["python"]=PythonLexer()
# Set the lexer for Python syntax highlighting
lexers["python"] = PythonLexer()

# Set paths
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
sys.path.insert(0, os.path.join(curr_path, '..'))
sys.path.insert(0, os.path.abspath('..'))

# Create content for deepforestr.md, skip the badge section
# Create content for deepforestr.md, skipping the badge section
deepforestr_title = """# Using DeepForest from R
An R wrapper for DeepForest is available in the [deepforestr package](https://github.com/weecology/deepforestr).
Commands are very similar with some minor differences due to how the wrapping process
using [reticulate](https://rstudio.github.io/reticulate/) works.
"""
file_obj = open('user_guide/deepforestr.md', 'w')
file_path = 'user_guide/deepforestr.md'
readme_url = 'https://raw.githubusercontent.com/weecology/deepforestr/main/README.md'
file_obj.write(deepforestr_title)

with urllib.request.urlopen(readme_url) as response:
lines = response.readlines()
badge_section = True
for line in lines:
line = line.decode("utf8")
if "## Installation" in line and badge_section:
badge_section = False
if not badge_section:
file_obj.write(line)
file_obj.close()

needs_sphinx = "1.8"
with open(file_path, 'w') as file_obj:
file_obj.write(deepforestr_title)

autodoc_default_options = {
'members': None,
'show-inheritance': None,
}
with urllib.request.urlopen(readme_url) as response:
lines = response.readlines()
badge_section = True
for line in lines:
line = line.decode("utf-8")
if "## Installation" in line:
badge_section = False
if not badge_section:
file_obj.write(line)

# Sphinx configuration
needs_sphinx = "1.8"
autodoc_default_options = {'members': None, 'show-inheritance': None}
autodoc_member_order = 'groupwise'
autoclass_content = 'both'

extensions = ["sphinx_design",
'nbsphinx', 'pygments.sphinxext', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary',
'sphinx.ext.doctest', 'sphinx.ext.githubpages', 'sphinx.ext.inheritance_diagram',
'sphinx.ext.intersphinx', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon',
'sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx_markdown_tables'
extensions = [
"sphinx_design", 'nbsphinx', 'pygments.sphinxext', 'sphinx.ext.autodoc',
'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.githubpages',
'sphinx.ext.inheritance_diagram', 'sphinx.ext.intersphinx', 'sphinx.ext.mathjax',
'sphinx.ext.napoleon', 'sphinx.ext.todo', 'sphinx.ext.viewcode',
'sphinx_markdown_tables'
]

nbsphinx_execute = 'never'
nbsphinx_allow_errors = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'DeepForest'
copyright = u"2019, Ben Weinstein"
author = u"Ben Weinstein"
version = release = __version__
# Project information
project = 'DeepForest'
copyright = "2019, Ben Weinstein"
author = "Ben Weinstein"
version = release = str(__version__.replace("dev0", ""))

exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']
pygments_style = 'sphinx'
todo_include_todos = False

# -- Options for HTML output -------------------------------------------
# HTML output options
html_theme = 'pydata_sphinx_theme'
json_url = 'https://raw.githubusercontent.com/henrykironde/DeepForest/refs/heads/switcher/version_switcher.json'


# Define the json_url for our version switcher.
json_url = "https://raw.githubusercontent.com/henrykironde/DeepForest/refs/heads/switcher/version_switcher.json"

# Define the version we use for matching in the version switcher.
version_match = os.environ.get("READTHEDOCS_VERSION")
# If READTHEDOCS_VERSION doesn't exist, we're not on RTD
# If it is an integer, we're in a PR build and the version isn't correct.
# If it's "latest" → change to "dev" (that's what we want the switcher to call it)
if not version_match or version_match.isdigit() or version_match == "latest":
# For local development, infer the version to match from the package.
if "dev" in release or "rc" in release:
version_match = "dev"
# We want to keep the relative reference if we are in dev mode
# but we want the whole url if we are effectively in a released version
json_url = "../version_switcher.json"
else:
version_match = f"v{release}"
elif version_match == "stable":
version_match = f"v{release}"
if ".dev" in version:
switcher_version = "dev"
elif "rc" in version:
switcher_version = version.split("rc", maxsplit=1)[0] + " (rc)"
else:
switcher_version = ".".join(version.split(".")[:2])

html_static_path = []
# html_theme_options = {
# "navbar_start": ["navbar-logo"],
# "navbar_align": "content",
# "navbar_center": ["navbar2"],
# "header_links_before_dropdown": 5,
# "secondary_sidebar_items": ["page-toc", "searchbox", "edit-this-page", "sourcelink"],
# "github_url": "https://github.com/weecology/DeepForest",
# }
html_theme_options = {
"navbar_start": ["navbar-logo"],
"navbar_align": "left",
Expand All @@ -117,115 +93,54 @@
"github_url": "https://github.com/weecology/DeepForest",
"navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"],
"switcher": {
"json_url": f"json_url{json_url}",
"version_match": version_match,
"json_url": "https://raw.githubusercontent.com/henrykironde/DeepForest/refs/heads/switcher/version_switcher.json",
"version_match": switcher_version,
},
}

# html_theme_options = {
# "external_links": [],
# "footer_start": ["pandas_footer", "sphinx-version"],
# "github_url": "https://github.com/pandas-dev/pandas",
# "twitter_url": "https://twitter.com/pandas_dev",
# "analytics": {
# "plausible_analytics_domain": "pandas.pydata.org",
# "plausible_analytics_url": "https://views.scientific-python.org/js/script.js",
# },
# "logo": {"image_dark": "https://pandas.pydata.org/static/img/pandas_white.svg"},
# "navbar_align": "left",
# "navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"],
# "switcher": {
# "json_url": "https://raw.githubusercontent.com/henrykironde/DeepForest/refs/heads/switcher/version_switcher.json",
# "version_match": switcher_version,
# },
# "show_version_warning_banner": True,
# "icon_links": [
# {
# "name": "Mastodon",
# "url": "https://fosstodon.org/@pandas_dev",
# "icon": "fa-brands fa-mastodon",
# },
# ],
# }


html_sidebars: Dict[str, Any] = {
"index": [],
"**": ["sidebar-nav-bs.html"],
}
html_static_path = ["_static"]

html_css_files = [
"css/getting_started.css",
"css/pandas.css",
]

# -- Options for HTMLHelp output ---------------------------------------

# Output file base name for HTML help builder.
# Output file base names for builders
htmlhelp_basename = 'deepforestdoc'

# -- Options for LaTeX output ------------------------------------------

latex_elements = {}
latex_documents = [
(master_doc, 'deepforest.tex', u'DeepForest Documentation', u'Ben Weinstein',
'manual'),
]

# -- Options for manual page output ------------------------------------

# One entry per manual page. List of tuples
man_pages = [(master_doc, 'deepforest', u'DeepForest Documentation', [author], 1)]

# -- Options for Texinfo output ----------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
latex_documents = [(master_doc, 'deepforest.tex', 'DeepForest Documentation', 'Ben Weinstein', 'manual')]
man_pages = [(master_doc, 'deepforest', 'DeepForest Documentation', [author], 1)]
texinfo_documents = [
(master_doc, 'deepforest', u'DeepForest Documentation', author, 'deepforest',
'One line description of project.', 'Miscellaneous'),
(master_doc, 'deepforest', 'DeepForest Documentation', author, 'deepforest', 'One line description of project.', 'Miscellaneous'),
]

source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}

# Temporary workaround to remove multiple build warnings caused by upstream bug
# See https://github.com/zulip/zulip/issues/13263 for details.
# Source suffix configuration
source_suffix = {'.rst': 'restructuredtext', '.md': 'markdown'}

# Suppress warnings due to recommonmark config not being cacheable
suppress_warnings = ["config.cache","toc.not_readable"]

suppress_warnings = ["config.cache", "toc.not_readable"]

# Custom CommonMark parser
class CustomCommonMarkParser(CommonMarkParser):

def visit_document(self, node):
pass


def setup(app: Any) -> None:
app.add_source_parser(CustomCommonMarkParser)
app.add_config_value(
'recommonmark_config',
{
'enable_eval_rst': True,
# Turn off recommonmark features we aren't using.
'enable_auto_doc_ref': False,
'auto_toc_tree_section': None,
'enable_auto_toc_tree': False,
'enable_math': False,
'enable_inline_math': False,
'url_resolver': lambda x: x,
},
True)

# Enable `eval_rst`, and any other features enabled in recommonmark_config.
# Docs: http://recommonmark.readthedocs.io/en/latest/auto_structify.html
# (But NB those docs are for master, not latest release.)
True
)
app.add_transform(AutoStructify)

# overrides for wide tables in RTD theme
app.add_css_file('theme_overrides.css') # path relative to _static
app.add_css_file('theme_overrides.css')
8 changes: 4 additions & 4 deletions version_switcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
{
"name": "dev",
"version": "dev",
"url": "https://deepforest.readthedocs.io/en/latest/",
"url": "https://deepforest.readthedocs.io/en/latest/"
},
{
"name": "1.3.3 (stable)",
"version": "v1.3.3",
"url": "https://deepforest.readthedocs.io/en/stable/",
"url": "https://deepforest.readthedocs.io/en/v1.3.3/",
"preferred": true
},
{
"name": "1.3.2",
"version": "v1.3.2",
"url": "https://deepforest.readthedocs.io/en/v1.3.2/",
},
"url": "https://deepforest.readthedocs.io/en/v1.3.2/"
}
]

0 comments on commit 01ab259

Please sign in to comment.