Comments (10)
Thanks for the bug report. I could reproduce the issue myself using the .. automodule::
directive for documenting your test code. The hyperlinks work with pydantic models if autodoc_pydantic
is deactivated - so this is definately a bug. This probably occurs due to the custom directives autodoc_pydantic
uses. I will take a look at it.
from autodoc_pydantic.
@tahoward The bug was related to how typed field references work. They always use the class
role. Until now, autodoc_pydantic
objects could not be referenced by the class role. However, this should be the case and it totally makes sense because pydantic models/settings are python classes.
Before merging the related PR, it would be great if you could test the bug fix on your site to confirm that my test case did indeed capture the incorrect behavior which you've encountered. To do so, please install the current dev release in your doc-building-environment via pip install git+git://github.com/mansenfranzen/[email protected]
and rebuild your docs.
from autodoc_pydantic.
I have this problem too, it turns out - just tried with that release and no dice, unfortunately.
from autodoc_pydantic.
@StephenHogg thanks for joining the conversation. I just rechecked if I accidentally messed up the v1.3.2-a.1
but it looks good. The following setup works fine for me with v1.3.2-a.1
:
conf.py
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
project = 'Test'
copyright = 'Test'
author = 'Test'
extensions = [
'sphinx.ext.autodoc',
'sphinxcontrib.autodoc_pydantic',
'sphinx.ext.napoleon',
]
test.py
from pydantic import BaseModel
class TestClass:
"""Test
Attributes:
model (TestModel): Model
"""
def __init__(self):
self.model = TestModel()
class TestModel(BaseModel):
pass
index.rst
.. automodule:: test
:members:
:undoc-members:
The generated doc strings contains the a link from the doc string body of TestClass
to TestModel
. Please notice the :members:
and :undoc-members:
directive options here. They are required in order to document all classes.
You've might come across a different issue here. If that's the case, please provide a minimal working example. The above code should at least work on your machine as it is (with sphinx 4.1.2 & pydantic 1.8.2), too. To ensure you have the correct version of autodoc_pydantic
installed in your local doc build environment, just create a new env and pip install git+git://github.com/mansenfranzen/[email protected]
.
from autodoc_pydantic.
My apologies, the problem I'm having appears to be because of the recursive autosummary thing.
from autodoc_pydantic.
No worries, now we know your issue is related to autosummary. Perhaps you could describe it in more detail in #33 if it provides any more insight.
from autodoc_pydantic.
@mansenfranzen Thanks for looking into this I'll pull in dev release and see what output looks like.
from autodoc_pydantic.
@mansenfranzen I seem to be unable to replicate the original issue on your v1.3.1
release when comparing against the v1.3.2-a.1
tag. I do see my Sphinx dep got bumped to 4.1.2 now. Locked it back to 4.1.1 but still unable to replicate my original issue. Are you still able to replicate with your v1.3.1
release?
from autodoc_pydantic.
@tahoward I can still reproduce the issue even with sphinx 4.1.2. The hyperlink does not show up in v1.3.1
but is present in v1.3.2-a.1
. Either way it works for you 😉.
from autodoc_pydantic.
@mansenfranzen Agreed!
from autodoc_pydantic.
Related Issues (20)
- Build failure with Enum under Pydantic 2.1, autodoc-pydantic 2.0.0 HOT 6
- @computed_field not showing in json schema HOT 2
- Deprecation warning for `ObjectMember` for Sphinx 7.2.2 HOT 3
- Package not honoring sphinxcontrib namespace package structure HOT 10
- Deprecation warning `sphinx.util.typing.stringify` for Sphinx v7.2.6 HOT 7
- Add `pydantic` classifier to help finding package HOT 2
- Cannot generate documentation when having class with arbitrary types HOT 1
- Cannot use `inherited-members` directive with autosummary HOT 5
- Generate output with nonvalidation methods HOT 4
- ForwardRef.__init__() got an unexpected keyword argument 'is_class' HOT 3
- Render field examples HOT 2
- Type aliases don't propagate for nested pydantic models with inherited members.
- Allow `autodoc_pydantic_field_signature_prefix` to be empty HOT 5
- Does `autodoc-pydantic` support the `pydantic.v1` compatibility layer? HOT 2
- `model_post_init` from `BaseModel` appears in the rendered documentation HOT 5
- [Feature Request] Print json schema as (collapsible) table HOT 2
- model_computed_fields is shown in rendered output HOT 3
- Consider dropping support for sphinx version 4.X HOT 3
- Model inherited from two parents does not seem to show inherited members HOT 1
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autodoc_pydantic.