Skip to content
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
4 changes: 4 additions & 0 deletions src/ansys/fluent/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""A package providing Fluent's Solver and Meshing capabilities in Python."""

import os
import pydoc
from typing import Any, Optional

import appdirs
Expand All @@ -12,6 +13,7 @@
launch_fluent,
)
from ansys.fluent.core.session import _BaseSession as Fluent # noqa: F401
from ansys.fluent.core.utils import fldoc
from ansys.fluent.core.utils.logging import LOG
from ansys.fluent.core.utils.setup_for_fluent import setup_for_fluent # noqa: F401

Expand Down Expand Up @@ -94,3 +96,5 @@ def disable_logging_to_file() -> None:
pass

BUILDING_GALLERY = False

pydoc.text.docother = fldoc.docother.__get__(pydoc.text, pydoc.TextDoc)
28 changes: 28 additions & 0 deletions src/ansys/fluent/core/utils/fldoc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pprint
import pydoc
import sys


def docother(self, object, name=None, mod=None, parent=None, maxlen=None, doc=None):
"""Produce text documentation for a data object."""
if isinstance(object, list):
indent_len = len(name and name + ' = ' or '') + 1
repr = pprint.pformat(object, width=maxlen, compact=True, indent=indent_len)
repr = "[" + repr[1:].lstrip()
else:
repr = self.repr(object)
if maxlen:
line = (name and name + ' = ' or '') + repr
chop = maxlen - len(line)
if chop < 0: repr = repr[:chop] + '...'
line = (name and self.bold(name) + ' = ' or '') + repr
# The source have been changed in 3.9, cpython commit id fbf2786c4c89430e2067016603078cf3500cfe94
if sys.version_info < (3, 9):
if doc is not None:
line += '\n' + self.indent(str(doc))
else:
if not doc:
doc = pydoc.getdoc(object)
if doc:
line += '\n' + self.indent(str(doc)) + '\n'
return line