I have some documents on Sphinx 2.x. In addition to an HTML version (make html), I want to export it in a PDF version as well, preferably using rst2pdf:
My documents have some figure images. Here's a snippet in index.rst.
.. figure:: ./_images/img01.png
Caption for img01.
.. figure:: ./_images/img02.png
Caption for img02.
I want to add "Figure <#>" in the beginning of every caption. Does anyone have any thoughts? Please note
numfig doesn't work with rst2pdf.
Update (3/22/2020). Add the following lines in conf.py.
numfig = True
numfig_format = {
'figure': 'Figure %s.'
}
numfig_secnum_depth = 1
In the HTML output it works.
In the rst2PDF version, you don't see "Figure #".
The :counter: directive doesn't work with Sphinx; I get the following error:
.. figure:: ./_images/img01.png
Figure :counter:`figure`. Caption for img01.
$ sphinx-build -b pdf ./source/ ./build/
Running Sphinx v2.4.4
/home/sarah/sphinx_test/lib/python3.6/importlib/__init__.py:126: RemovedInSphinx30Warning: sphinx.environment.NoUri is deprecated.
Check CHANGES for Sphinx API modifications.
return _bootstrap._gcd_import(name[level:], package, level)
Initiated sphinxcontrib-images backend: `sphinxcontrib_images_lightbox2.lightbox2:LightBox2`
building [mo]: targets for 0 po files that are out of date
building [pdf]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
Exception occurred:
File "/home/sarah/sphinx_test/lib/python3.6/site-packages/docutils/nodes.py", line 439, in copy
return self.__class__(reprunicode(self), rawsource=self.rawsource)
AttributeError: 'CounterNode' object has no attribute 'rawsource'
The full traceback has been saved in /tmp/sphinx-err-1bzghsm6.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Related
I am using sphinx for documentation. When I am using "make confluence", I am getting the below warnings from the index.rst file.
How can I remove these warnings? Also, Table of content is not working in confluence due to these warning but the documentation is getting created in the code.
Any suggestion/help will be highly appreciable.
[4px#learning-2 docs]$ make confluence
Running Sphinx v4.2.0
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [confluence]: targets for 0 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
/usr/lib64/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
return f(*args, **kwds)
/usr/lib64/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
return f(*args, **kwds)
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
/home/4px/sphinx/docs/source/index.rst:: WARNING: unable to build link to document due to missing title (in index): genindex
/home/4px/sphinx/docs/source/index.rst:: WARNING: unable to build link to document due to missing title (in index): py-modindex
/home/4px/sphinx/docs/source/index.rst:: WARNING: unable to build link to document due to missing title (in index): search
publishing documents... [100%] index
Publish point: https://<........>.atlassian.net/wiki/spaces/DOCS/pages/4194009282
building intersphinx... done
build succeeded, 3 warnings.
index.rst file-
.. 4px documentation master file, created by
sphinx-quickstart on Tue Oct 26 11:19:49 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
API Documentation
**************************
CODE DOCUMENTATION
====================================
.. toctree::
:hidden:
index
featureSelection
==================
.. automodule:: featureSelection
:members:
interpolate
============
.. automodule:: interpolate
:members:
pets
============
.. automodule:: pets
:members:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
I got one github issue regarding this warning, but it was for older version.
Sphinx 2.2.2 warning · Issue #265 · sphinx-contrib/confluencebuilder
The below warnings are removed after cleaning up the index.rst file and creating individual rst file for each python script instead of adding structured format in an index.rst as above.
It yields another advantage of creating TOC page in confluence on its own.
The structure of index.rst should be below in cd docs/sources directory, where assets, plant,Site, pipeline are the name of the python script
index.rst-
.. spectRRa documentation master file, created by
sphinx-quickstart on Fri Apr 24 11:55:57 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
**API Docs**
***************
.. toctree::
assets
plants
pipelines
sites
Also create all individual rst file in cd docs/sources/ directory.
Ex-For assets.py script,the assets.rst file will be below.
assets.rst-
.. spectRRa documentation master file, created by
sphinx-quickstart on Fri Apr 24 11:55:57 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. toctree::
:maxdepth: 2
:caption: Contents:
**Assets**
=================
.. automodule:: assets
:members:
Note-Pls don't change indentation otherwise, it won't work and throw indentation warnnings.
Ref Link-Stack overflow TOC page generation in confluence using sphinx confluence builder
Sphinx Documentation
I'm not sure if this will help, but your reStructuredText has random indentation and mismatched heading underline lengths. White space matters in reStructuredText. Try cleaning it up, like so:
API Documentation
*****************
CODE DOCUMENTATION
==================
.. toctree::
:hidden:
index
featureSelection
================
.. automodule:: featureSelection
:members:
interpolate
===========
.. automodule:: interpolate
:members:
pets
====
.. automodule:: pets
:members:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
I installed the latest version of RStudio (RStudio 1.1.423 - Windows Vista / 7/8/10).
I'm trying to publish to RPubs, but in Global Options does not appear the option for Rpubs.
When I request Publish Document, the following error appears: Error occurred while executing method.
Rprofile:
I entered the command: options (rpubs.upload.method = "internal") at line 25 of Rprofile, but it did not resolve.
The solution is provided by a careful rereading of http://rstudio-pubs-static.s3.amazonaws.com/25030_8e9c9ffc3b3c423d9381d81543423502.html
"Put in options(rpubs.upload.method = “internal”) and no other text at all". Meaning that this line of code is the only code present in the .Rprofile file.
Previously I had been adding the line to a copy of the rest of the Rprofile text. The unnecessary code was the culprit.
I had the same error before. Turns out it was due to having an accent mark in a folder name from my directory (í). I just modified that one folder name and it worked fine.
I've got a particular bug in my environment such that I cannot consistently knit Rmarkdown files to HTML, Word documents, or PDFs. The ability to knit varies across by file type.
HTML - Sometimes it knits
Word document - Sometimes it knits
PDF - Never knits. Always throws the same error
The error is:
Segmentation fault/access violation in generated code
Error: pandoc document conversion failed with error 1
Up until a week ago, I was able to knit to all three file types in the same environment so this is a relatively recent bug. The high-level specs of my environment are:
OS: Windows 10
R: 3.4.3
RStudio: 1.1.419
knitr: 1.19
rmarkdown: 1.8
pandoc: 1.19.2.1
MiKTeX : 2.9
As an example of the inconsistency in the ability to knit, I crated a new .Rmd file in RStudio which creates the familiar standard template of summary(cars) and plot(pressure) etc. I didn't change anything about it. I was able to knit it successfully to HTML once, Word .docx once, and then I tried to knit to PDF and got the error above. I then went back and attempted to knit to both HTML and Word and received the error even though nothing changed from the original knit. This is just an example of the type of behavior. Different documents behave differently.
To troubleshoot, I've reinstalled R and RStudio (I believe pandoc comes up with the RStudio install so I've effectively reinstalled pandoc too). The reinstallation did not help. I've tried clearing the Knitr Cache. That didn't work either. I've browsed SO and the internet and found a few similar errors related to the Glasgow-Haskell compiler, but I have no idea what that is and if it's the source of the issue.
Here is an example of the .Rmd file that throws the error:
---
title: "Untitled"
author: "Vypa"
date: "February 8, 2018"
output:
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
And here is the full console error:
Segmentation fault/access violation in generated code
Error: pandoc document conversion failed with error 1
In addition: Warning message:
running command '"C:/Users/Vypa/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS tst.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output tst.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\Vypa\Documents\R\R-3.4.3\library\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\Vypa\AppData\Local\Temp\RtmpI9Gxsx\rmarkdown-str5db029544a23.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"' had status 1
Execution halted
Any help or thoughts would be appreciated.
Encountered the same problem after a recent install of R & RStudio on Win10. Pandoc problem showed up on edit and knitr of previously err free .rmd file.
Resolved after installing latest preview ver of RStudio at
https://www.rstudio.com/products/rstudio/download/preview/
Updating pandoc fixed this for me.
https://pandoc.org/installing.html
Thanks #EuGENE. Adding here as an answer for clarity.
I'm using Sublime Text 3 on Windows 7 with Package Control installed, and I want to install a couple packages for syntax highlighting. I'm told I have to do this by hitting Ctrl+Shift+P and clicking 'Package Control: Install Package'. At that point something is supposed to appear where I can enter text, but as far as I can tell all it does is say, 'Loading Repositories [=====]' at the bottom for a half second and then stop. Besides the main editor window, there's nowhere else new to enter text or a link or something. Am I missing something from the process, or did I not understand one of the steps correctly?
Edit: It shows this error message in the console whenever I try to access the list of packages;
Exception in thread Thread-6:
Traceback (most recent call last):
File "./threading.py", line 901, in _bootstrap_inner
File "package_control.commands.install_package_command in S:\Users\Nicholas\AppData\Roaming\Sublime Text 3\Installed Packages\Package Control.sublime-package", line 43, in run
File "package_control.package_installer in S:\Users\Nicholas\AppData\Roaming\Sublime Text 3\Installed Packages\Package Control.sublime-package", line 54, in make_package_list
File "package_control.package_manager in S:\Users\Nicholas\AppData\Roaming\Sublime Text 3\Installed Packages\Package Control.sublime-package", line 260, in list_available_packages
File "package_control.downloaders.background_downloader in S:\Users\Nicholas\AppData\Roaming\Sublime Text 3\Installed Packages\Package Control.sublime-package", line 52, in get_provider
KeyError: 'http://merlinthered.github.com/sublime-rainmeter/'
As far as I can tell, the error is simply saying that it can't download, access or parse a certain package. You may get more information about the specific error by posting it to the Package Control GitHub issues page as the someone that knows the inner workings of the package control might be able to help you better.
You could try an reinstall of Sublime Text 3 and the Package Control. You may want to back-up your settings and packages, in case you want to go back to the current setup. You can find these using Preferences > Browse Packages.
I am trying to compile a .pro file using qmake and Qt4 to get a library from qttestrunnerlib.pro but I get this error:
~/docs/UT_Cpp_Test/main/cppDir/src/qttestrunner$ qmake qttestrunnerlib.pro
uic: Error in line 6, column 14 : Unexpected element name
uic: Error in line 6, column 14 : Unexpected element name
When I use Qt3 it works, and I get my lib successfully. But I want to upgrade it to Qt4. Is it possible? and what should I do?
I've used uic3 from the qt3-support package (on gentoo at least)
uic3 -convert ui-file-qt3.ui -o ui-file-qt4.ui
That is because the designer in qt4 is different from qt3. means ui files generated by qt3 and qt4 are not the same. That's why the unexpected element name error!
The uic reads a user interface definition (.ui) file in XML as generated by Qt
Designer and creates corresponding C++ header or source files.
Easiest way to solve is, use your qt4 ide to open you form and it will ask for
conversion.Then use the newly created ui for your compilation.