arello-mobile / sphinx-confluence Goto Github PK
View Code? Open in Web Editor NEWAtlassian Confluence extension for sphinx
License: MIT License
Atlassian Confluence extension for sphinx
License: MIT License
The current ref implementation seems to only work with labels in the same document, while Sphinx allows refs to point to any label in the documentation.
When I do make html
the output is in the Confluence storage format. However, this is not the case for make json
. It appears that there is no translation occurring. May be related to changes made in #12
Making the following change to the setup
function seems to correct this...
...
if LooseVersion(sphinx.__version__) >= LooseVersion("1.4"):
app.set_translator("html", HTMLConfluenceTranslator)
app.set_translator('json', HTMLConfluenceTranslator) # make it work for json, too.
...
Although a separate issue... I also tried doing sphinx-build -b json_conf
but got the following exception.
Traceback (most recent call last):
File "/Users/spenceryoung/ISS/lib/python3.6/site-packages/sphinx/cmdline.py", line 305, in main
opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
File "/Users/spenceryoung/ISS/lib/python3.6/site-packages/sphinx/application.py", line 226, in __init__
self.builder = self.create_builder(buildername)
File "/Users/spenceryoung/ISS/lib/python3.6/site-packages/sphinx/application.py", line 306, in create_builder
return self.registry.create_builder(self, name)
File "/Users/spenceryoung/ISS/lib/python3.6/site-packages/sphinx/registry.py", line 82, in create_builder
return self.builders[name](app)
File "/Users/spenceryoung/ISS/lib/python3.6/site-packages/sphinx_confluence/__init__.py", line 59, in __init__
self.translator_class = HTMLConfluenceTranslator
AttributeError: can't set attribute
Exception occurred:
File "/Users/spenceryoung/ISS/lib/python3.6/site-packages/sphinx_confluence/__init__.py", line 59, in __init__
self.translator_class = HTMLConfluenceTranslator
AttributeError: can't set attribute
I am using Sphinx 1.6.5
Hey! We started using sphinx-confluence and it so far it has been great.
One feature we are missing is to structure the pages in a hierarchy that follows the documentation. Normally, sphinx produces an index that is usually shown on the side bar. This tool currently uploads all pages as children of one page, which results in a flat index, loosing the hierarchy encoded in the source rst/md files.
Would it be possible to upload them following a hierarchy?
I am currently planning on doing that with my own script to shuffle the pages after uploaded, but any pointers so I can help would be appreciated.
Can you do a write up or blog post on how you go from the json output to confluence? I can take my sphinx documentation and generate build/json/*.fjson
files and I've read through the document storage format. But at this point, I'm struggling.
Do create a new page you do this:
curl -u admin:admin -X POST -H 'Content-Type: application/json' --data-binary @filename.json" http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool
And the content of that file looks like so:
{
"body": {
"storage": {
"representation": "storage",
"value": "<p>This is a new page</p>"
}
},
"space": {
"key": "TST"
},
"title": "new page",
"type": "page"
}
Whereas the json out put would look like this:
{
"alabaster_version": "0.7.6",
"body": "<p>this is a new page</p>",
"current_page_name": "index",
"customsidebar": null,
"display_toc": true,
"meta": {},
"metatags": "",
"next": null,
"parents": [],
"prev": null,
"rellinks": [
[
"genindex",
"General Index",
"I",
"index"
]
],
"sidebars": null,
"sourcename": "index.txt",
"title": "A New Page",
"toc": "<ul>\n<li><a class=\"reference internal\" href=\"#\">New Page</a></li>\n</ul>\n"
}
It looks like what I have to do is create a tool to loop over files ending in .fjson, extract the body tag and create a body['storage']['value'] tag, but I feel like we're missing something. Shouldn't these json files be in the confluence format already, missing only space key (or better yet, we can configure the space key at build)?
Is it correct that this plugin is only able to build a single file (the master index file) and not linked/mentioned ones in toctree directives?
If I try to use it, sphinx claims that all my documentation files are not part of a toctree and therefore they get not build.
I guess this is because the toctree directives is overwritten by this extension.
Any ideas how to avoid this?
The README.md "How use it" section says that after installing the plugin and building html or json, "the results must be in Confluence Storage Format". Is there a step that must be taken to convert to this format, or something that needs to be added to to the config file for confluence-publisher?
Sphinx in 1.5.1 version set html_translator_class as deprecated
This diff should fix this:
diff --git a/sphinx_confluence/__init__.py b/sphinx_confluence/__init__.py
index 1c6eb3d..322c662 100644
--- a/sphinx_confluence/__init__.py
+++ b/sphinx_confluence/__init__.py
@@ -543,7 +543,7 @@ def setup(app):
app.config.html_theme_path = [get_path()]
app.config.html_theme = 'confluence'
app.config.html_scaled_image_link = False
- app.config.html_translator_class = 'sphinx_confluence.HTMLConfluenceTranslator'
+ app.set_translator("HTMLConfluenceTranslator", HTMLConfluenceTranslator)
app.config.html_add_permalinks = ''
jira_issue = JiraIssueRole('jira_issue', nodes.Inline)
Source:
http://www.sphinx-doc.org/en/1.5.1/changes.html
html_translator_class is now deprecated. Use Sphinx.set_translator() API instead.
While this module converts Sphinx documentation into so called internal storage format used by Confluence its readme page is missing to give any information regarding how someone would be able to upload these to Confluence (preferably in a an automated way).
Docs that use automodule aren't currently supported. I get the following error: ERROR: Unknown directive type "automodule".
As in question. After make html
I cannot see anything different with or without the extension enabled.
Am happy to join as a collaborator to help develop and maintain this package.
When running make singlehtml
I am getting the following output
Running Sphinx v1.7.4
WARNING: while setting up extension sphinx_confluence: directive 'toctree' is already registered, it will be overridden
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [singlehtml]: all documents
updating environment: 11 added, 0 changed, 0 removed
reading sources... [100%] scope
The result for me is that only the main page it taken into account for the content generation and that the toctree is not taken into account.
My setup (normally) uses the sphinx_rdt_theme
The installation instructions should say:
extensions. = ['sphinx_confluence']
html_translator_class = 'sphinx_confluence.HTMLConfluenceTranslator'
instead of
extensions. = ['confluence']
html_translator_class = 'confluence.HTMLConfluenceTranslator'
Error on install:
Traceback (most recent call last):
File "setup.py", line 6, in
open(os.path.join(BASE_DIR, 'README.md')).read()
IOError: [Errno 2] No such file or directory: '/home/jatkinso/Downloads/sphinx-confluence-0.0.1/README.md'
Hello!
I receive a error when I trying to convert our documentation with your plugin. May be this log will help you to find a problem:
# Sphinx version: 1.3.3
# Python version: 2.7.5+ (CPython)
# Docutils version: 0.12 release
# Jinja2 version: 2.8
# Last messages:
# /home/shmele/project/src/docs/source/modules/one/forms.rst:: WARNING: document isn't included in any toctree
# /home/shmele/project/src/docs/source/modules/one/models.rst:: WARNING: document isn't included in any toctree
# /home/shmele/project/src/docs/source/modules/one/reports.rst:: WARNING: document isn't included in any toctree
# /home/shmele/project/src/docs/source/modules/two.rst:: WARNING: document isn't included in any toctree
# /home/shmele/project/src/docs/source/modules/three.rst:: WARNING: document isn't included in any toctree
# /home/shmele/project/src/docs/source/modules/four.rst:: WARNING: document isn't included in any toctree
# done
# preparing documents...
# done
# writing output... [ 6%] glossary
# Loaded extensions:
# sphinx.ext.autodoc (1.3.3) from /home/shmele/project/local/lib/python2.7/site-packages/sphinx/ext/autodoc.pyc
# sphinx.ext.intersphinx (1.3.3) from /home/shmele/project/local/lib/python2.7/site-packages/sphinx/ext/intersphinx.pyc
# sphinx.ext.doctest (1.3.3) from /home/shmele/project/local/lib/python2.7/site-packages/sphinx/ext/doctest.pyc
# alabaster (0.7.6) from /home/shmele/project/local/lib/python2.7/site-packages/alabaster/__init__.pyc
# sphinx.ext.viewcode (1.3.3) from /home/shmele/project/local/lib/python2.7/site-packages/sphinx/ext/viewcode.pyc
# sphinx.ext.coverage (1.3.3) from /home/shmele/project/local/lib/python2.7/site-packages/sphinx/ext/coverage.pyc
# sphinx.ext.todo (1.3.3) from /home/shmele/project/local/lib/python2.7/site-packages/sphinx/ext/todo.pyc
# sphinx_confluence (unknown version) from /home/shmele/project/local/lib/python2.7/site-packages/sphinx_confluence/__init__.pyc
Traceback (most recent call last):
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 240, in main
app.build(opts.force_all, filenames)
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx/application.py", line 266, in build
self.builder.build_update()
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 252, in build_update
'out of date' % len(to_build))
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 323, in build
self.write(docnames, list(updated_docnames), method)
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 361, in write
self._write_serial(sorted(docnames), warnings)
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 369, in _write_serial
self.write_doc(docname, doctree)
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 439, in write_doc
self.docwriter.write(doctree, destination)
File "/home/shmele/project/local/lib/python2.7/site-packages/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx/writers/html.py", line 53, in translate
self.document.walkabout(visitor)
File "/home/shmele/project/local/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/home/shmele/project/local/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/home/shmele/project/local/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/home/shmele/project/local/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/home/shmele/project/local/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/home/shmele/project/local/lib/python2.7/site-packages/docutils/nodes.py", line 166, in walkabout
visitor.dispatch_visit(self)
File "/home/shmele/project/local/lib/python2.7/site-packages/docutils/nodes.py", line 1882, in dispatch_visit
return method(node)
File "/home/shmele/project/local/lib/python2.7/site-packages/sphinx_confluence/__init__.py", line 258, in visit_reference
if node.get('internal') and self.builder.has_title(self.document):
AttributeError: 'StandaloneHTMLBuilder' object has no attribute 'has_title'
It my first time, when I trying to use your extension.
It would be nice to have an example on how to upload or import the resultant docs into Confluence. The documentation around importing documents in the Confluence Storage Format seem scarce.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.