Comments (5)
Unfortunately, I do not know how to integrate it to Sphinx properly, i.e. so you can integrate it with a toctree. Sphinx uses docutils
internally, and docutils
is a freaking mess. :(
However, it's not true that you need to do absolute links. You can do relative (to docs/
) links.
The point of this extension is to have Sphinx as the only tool you need to produce all-in-one docs, where you have your Sphinx documentation and ReDoc-rendered OpenAPI spec. I.e. perform ReDoc bundling and spec copying when you run Sphinx to build the docs.
from redoc.
An imperfect solution is to link the ReDoc rendered spec to the main documentation with, the info->description
field in the OpenAPI spec, e.g.
"info": {
"description": "See <a href='./index.html'>main documentation</a> for more information about this project.",
[...]
}
and then in Sphinx create a new page that links to ReDoc rendered spec in the description.
Adding ReDoc rendered spec to sphinx's table of content (without passing by an intermediary page) would be ideal, and there is related discussion in sphinx-doc/sphinx#701 but with no clear solution as far as I can tell.
from redoc.
What I'm just trying to do is to use the Sphinx raw:: html
directive to include a file with the HTML fragments in it. It's a bit messy, but it sort of works when I pimp my build system to do the heavy lifting for me:
- Strip the HTML boiler plate out of it (only keeping everything within the
<body>...</body>
tags in a fileopenapi.html
- Raw include this file (above) with HTML content
- Add some boiler plate of raw HTML resizing the width of the 3-panel-view to suit my needs.
I'm not a HTML/UI person, but with a bit of help this is what I've cobbled up and what I'm using (for now):
.. only:: html
.. _specs-details:
OpenAPI Specs Details
=====================
.. raw:: html
<script>
function resizeOpenapiElement() {
var openapiElement = document.getElementById('openapiWidget');
var parentElement = openapiElement.parentNode;
parentElement.style.width = '150%';
}
document.body.addEventListener('load', resizeOpenapiElement, true);
</script>
<div id="openapiWidget">
.. raw:: html
:file: _static/openapi.html
.. raw:: html
</div>
I hope that helps already. And I'm happy as, if somebody has suggestions on how to handle this in a tidier way ... ;-)
from redoc.
Another update on this:
I am now just injecting a place holder {{openapi_redoc}}
between the opening/closing <div>
tags in the message above. I'm extracting the content of the <body>
only from the generated ReDoc HTML content, which I'm then injecting for the above place holder. This is all (Python) scripted to give easily working reproducible builds.
I have subtly altered the Sphinx Makefile
to call my patch_openapi_redoc.py
script to do all the steps of the job described above right after the Sphinx build.
from redoc.
I tried the above .. only:: html
snippet and is there a way we can use the .yaml
file instead of the path to the .html
file?
I have placed the yaml file in custom directory (specs/openapi.yaml), I get the entire junk (unformatted) of yaml in the section "OpenAPI Specs Details".
from redoc.
Related Issues (20)
- Can't use relative URL to spec.yaml file HOT 4
- possibility to config to use other reddoc.js
- "the proof" is not working HOT 1
- openapi: 3.0.1 support HOT 3
- Fails to build some targets HOT 1
- Move to sphinx-contrib organization? HOT 6
- Download YAML file too HOT 2
- TypeError('sequence item 0: expected str instance, int found',) when we do make html HOT 1
- server url is not correct HOT 4
- The generated doc don't show any exemple of request and response HOT 2
- Ordering of endpoints is random with the use of yaml library : switch to oyaml HOT 1
- Minor Issue in docs HOT 2
- No "type" specified at "/paths/~1test/post/parameters/0". Automatically detected: "object"
- Error in docs
- Referenced `yml` files are not copied HOT 2
- No Support for OpenAPI 3.0 HOT 1
- Internationalization
- Sphinx-contrib extension error: urlopen error [Errno -3]
- Redoc page rendering only when used in toctree directive.
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 redoc.