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

Initial work on Ice for Python API reference documentation #2535

Merged
merged 16 commits into from
Jul 25, 2024

Conversation

pepone
Copy link
Member

@pepone pepone commented Jul 19, 2024

This PR updates Ice for Python API docs:

The documentation is generated with sphinx, one of the standard tools for documenting Python projects.

The PR is getting quite large, I want to get some feedback before I add more changes.

@pepone pepone requested review from externl and bernardnormier July 23, 2024 15:21
@pepone pepone marked this pull request as ready for review July 23, 2024 15:21
Comment on lines 427 to 440
_out << nl << tripleQuotes;
_out << nl << "Immediately marshals the result of an invocation of " << name;
_out << nl << "and returns an object that the servant implementation must return";
_out << nl << "as its result.";
_out << nl;
_out << nl << "Args:";
_out << nl << " result: The result (or result tuple) of the invocation.";
_out << nl << " current: The Current object passed to the invocation.";
_out << nl;
_out << nl << "Returns";
_out << nl << " An object containing the marshaled result.";
_out << nl << tripleQuotes;
_out << nl << "return IcePy.MarshaledResult(result, _M_" << getAbsolute(p) << "._op_" << fixedOpName
<< ", current.adapter.getCommunicator().getImpl(), current.encoding)";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update this to use numpy style..

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the standard make file for Sphinx generated by sphinx-quickstart

PyVarObject_HEAD_INIT(0, 0) "IcePy.Endpoint", /* tp_name */
sizeof(EndpointObject), /* tp_basicsize */
0, /* tp_itemsize */
PyVarObject_HEAD_INIT(0, 0) "Ice.Endpoint", /* tp_name */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to revert this change. I was testing the direct exposure of this component as part of the Ice module and documenting it in a .pyi file.

Using the autoapi extension (https://sphinx-autoapi.readthedocs.io/en/latest/) seemed to work initially. However, I reverted to the autodoc extension because autoapi does not support our current generated code due to the conditional class definitions.

@@ -1768,7 +1768,7 @@ IcePy::wrapObjectAdapter(const Ice::ObjectAdapterPtr& adapter)
{
return nullptr;
}
PyObject* wrapperType = lookupType("Ice.ObjectAdapterI.ObjectAdapterI");
PyObject* wrapperType = lookupType("Ice._ObjectAdapterI.ObjectAdapterI");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _ prefix is used for private modules. I renamed private classes to use this prefix to help exclude them from the generated documentation.

@@ -2249,8 +2249,7 @@ IcePy::createProxy(const Ice::ObjectPrx& proxy, const Ice::CommunicatorPtr& comm
{
if (!type)
{
PyTypeObject* proxyType = &ProxyType; // Necessary to prevent GCC's strict-alias warnings.
type = reinterpret_cast<PyObject*>(proxyType);
type = lookupType("Ice.ObjectPrx");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ice.ObjectPrx is the public base proxy type, it delegates to the parent class IcePy.ObjectPrx.

@@ -183,3 +183,5 @@ def _warn(self, msg):
StateRunning = "running"
StateCancelled = "cancelled"
StateDone = "done"

__all__ = ["Future", "wrap_future", "FutureBase"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The all variable specifies the public API and controls what is exposed when using the import * syntax. This prevents duplication warnings during documentation generation by avoiding the re-export of imported items, which would otherwise result in warnings indicating they are defined in multiple places.

@@ -0,0 +1,45 @@

from .Current import Current
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The private implementation of Ice.Current.

@@ -0,0 +1,56 @@
# Copyright (c) ZeroC, Inc. All rights reserved.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied it here because of Ice._ArrayUtil is not exported anymore.

python/modules/IcePy/Current.cpp Outdated Show resolved Hide resolved
python/python/Ice/_CommunicatorI.py Outdated Show resolved Hide resolved
@pepone pepone marked this pull request as ready for review July 24, 2024 18:09
@pepone pepone requested a review from bernardnormier July 24, 2024 18:09
Copy link
Member

@bernardnormier bernardnormier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

For LoggerI in file _LoggerI.py, is this naming inconsistency on purpose?


import IcePy

class ObjectPrx(IcePy.ObjectPrx):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use delegation to the C++ object, like for example Communicator. Am I missing something?

@bernardnormier bernardnormier self-requested a review July 24, 2024 19:13
Comment on lines 9 to 11
Add your content using ``reStructuredText`` syntax. See the
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
documentation for details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we should delete this snippet?

@pepone
Copy link
Member Author

pepone commented Jul 24, 2024

For LoggerI in file _LoggerI.py, is this naming inconsistency on purpose?

The _ prefix is used by convention in Python for private modules/members.

.github/workflows/docs.yml Outdated Show resolved Hide resolved
@pepone pepone merged commit a6674e6 into zeroc-ice:main Jul 25, 2024
18 checks passed
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
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

Successfully merging this pull request may close these issues.

3 participants