-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Strip function definition in literalinclude -> pyobject #13594
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
Comments
Hi Sam, Thanks for creating the issue. Out of interest, who is 'we'? Would be useful to know how widespread something like this would be. I wonder if an option would be to make A |
aio-libs in this case. Starting with all the examples in aiohttp: https://docs.aiohttp.org/en/stable/
That would probably be good enough for us, though it's not quite as maintainable in the sense that if a function signature changes and gets wrapped over multiple lines, it would now appear in the docs until someone noticed (or the reverse, where a couple of lines disappears from the docs). |
Thinking that through, for our case we'd basically just be wrapping them in a basic function that serves no other purpose. So, the function signature is very unlikely to change after being created. So, this would work perfectly fine. |
As an example, we just merged this: I'd like the 3rd example in that section to be rendered without the function def. If we get this feature, we'll then want to extract all existing code blocks from the docs in future and do the same thing. |
Uh oh!
There was an error while loading. Please reload this page.
Is your feature request related to a problem? Please describe.
Simple examples in docs tend to get out of sync with APIs etc. To fix this, we want to type check that code with mypy.
The only properly maintainable way to include such code would be using the literalinclude directive with pyobject (e.g. to ensure we don't miss line number changes etc.). To use pyobject, we need to put the code into a function (we'd probably need to do that because it's mostly async code anyway).
This results in simple examples all appearing with a function signature which is not relevant to the example. So, we'd like to see a directive that excludes the function signature.
Describe the solution you'd like
In the docs, something like:
Resulting in rendering like:
Describe alternatives you've considered
I can't see any alternatives that are worth doing. Will likely just leave the code in the docs until a solution like this is provided.
The text was updated successfully, but these errors were encountered: