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

Removing edit button fix #2341

Merged
merged 6 commits into from
Sep 28, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions doc/source/_templates/edit-this-page.html

This file was deleted.

52 changes: 3 additions & 49 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from ansys.mapdl import core as pymapdl
from ansys.mapdl.core import __version__
from ansys.mapdl.core.docs import linkcode_resolve

# Manage errors
pyvista.set_error_output_file("errors.txt")
Expand Down Expand Up @@ -54,7 +53,7 @@
cname = os.getenv("DOCUMENTATION_CNAME", "mapdl.docs.pyansys.com")

REPOSITORY_NAME = "pymapdl"
USERNAME = "pyansys"
USERNAME = "ansys"
BRANCH = "main"


Expand All @@ -74,17 +73,14 @@
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.extlinks",
# sphinx.ext.linkcode add the button ``[Source]`` to each website.
# The link of that button is created by calling ``linkcode_resolve``
# function which we overwrite in ansys.mapdl.core.docs
"sphinx.ext.linkcode",
"sphinx.ext.intersphinx",
"sphinx_autodoc_typehints",
"sphinx_copybutton",
"sphinx_gallery.gen_gallery",
"sphinxemoji.sphinxemoji",
"sphinx.ext.graphviz",
"sphinx_reredirects",
"ansys_sphinx_theme.extension.linkcode",
]

# Intersphinx mapping
Expand Down Expand Up @@ -288,6 +284,7 @@
"github_repo": REPOSITORY_NAME,
"github_version": BRANCH,
"doc_path": DOC_PATH,
"source_path": "src",
}
html_show_sourcelink = False

Expand Down Expand Up @@ -367,48 +364,6 @@
epub_exclude_files = ["search.html"]


def setup_to_py(
app: Sphinx, pagename: str, templatename: str, context, doctree
) -> None:
"""Add a function that jinja can access for returning an "edit this page" link pointing to `main`."""

def fix_edit_link_button(link: str) -> str:
"""Transform "edit on github" links and make sure they always point to the main branch.

Args:
link: the link to the github edit interface

Returns:
the link to the tip of the main branch for the same file
"""
# Create custom 'edit' URLs for API modules since they are dynamically generated.
doc_path = "/".join(link.split("/")[:-1])
file_name = link.split("/")[-1]

if GALLERY_EXAMPLES_PATH in doc_path:
# We are in a python example
doc_path = doc_path.replace(
f"{DOC_PATH}/{GALLERY_EXAMPLES_PATH}", EXAMPLES_ROOT
)
file_name = (
os.path.basename(file_name).replace(source_suffix, "")
+ f".{DEFAULT_EXAMPLE_EXTENSION}"
)
return f"{doc_path}/{file_name}"

elif "_autosummary" in link:
# This is an API example
fullname = link.split("_autosummary")[1][1:]
return linkcode_resolve(
"py", {"module": "ansys.mapdl.core", "fullname": fullname}, edit=True
)

else:
return link

context["fix_edit_link_button"] = fix_edit_link_button


def setup(app: Sphinx):
"""Add custom configuration to sphinx app.

Expand All @@ -417,7 +372,6 @@ def setup(app: Sphinx):
app : sphinx.application.Sphinx
The Sphinx application.
"""
app.connect("html-page-context", setup_to_py)

# Adding apdl syntax highlighting
from pygments.lexers.apdlexer import apdlexer
Expand Down
140 changes: 0 additions & 140 deletions src/ansys/mapdl/core/docs.py

This file was deleted.

52 changes: 0 additions & 52 deletions tests/test_docs.py

This file was deleted.