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

Simplify doc build #2923

Open
germa89 opened this issue Mar 21, 2024 · 1 comment
Open

Simplify doc build #2923

germa89 opened this issue Mar 21, 2024 · 1 comment

Comments

@germa89
Copy link
Collaborator

germa89 commented Mar 21, 2024

There is a chunk of code which seems unnecesary:

if pymapdl.BUILDING_GALLERY: # pragma: no cover
LOG.debug("Building gallery.")
# launch an instance of pymapdl if it does not already exist and
# we're allowed to start instances
if GALLERY_INSTANCE[0] is None:
mapdl = launch_mapdl(
start_instance=True,
cleanup_on_exit=False,
loglevel=loglevel,
set_no_abort=set_no_abort,
**start_parm,
)
GALLERY_INSTANCE[0] = {"ip": mapdl._ip, "port": mapdl._port}
return mapdl
# otherwise, connect to the existing gallery instance if available
elif GALLERY_INSTANCE[0] is not None:
mapdl = MapdlGrpc(
ip=GALLERY_INSTANCE[0]["ip"],
port=GALLERY_INSTANCE[0]["port"],
cleanup_on_exit=False,
loglevel=loglevel,
set_no_abort=set_no_abort,
use_vtk=use_vtk,
**start_parm,
)
if clear_on_connect:
mapdl.clear()
return mapdl

This does not need to be in the library.

We can just use Sphinx events to spawn an MAPDL instance.

The pseudo code is as follow:

def spawn_mapdl_instance(app, docname, source):
     app._mapdl = launch_mapdl()  # it should account for local and remote.

def kill_mapdl_instance(app, exception):
    app._mapdl.exit()

def setup(app):
    app.connect('builder-inited', spawn_mapdl_instance)
    app.connect('build-finished', kill_mapdl_instance)

This way, we can remove the mentioned code from the library itself. It has been long irritating my eyes.

Reference: https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx-core-events

@germa89
Copy link
Collaborator Author

germa89 commented Mar 21, 2024

Related to this #2922

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant