Sphinx substitution in URL - python-sphinx

I have two projects A and B, project A's docs are being hosted for different versions, so the doc urls have the format
http://example.org/A/1.0.0/+d/index.html
http://example.org/A/1.0.1/+d/index.html
http://example.org/A/1.2.3/+d/index.html
Project B depends on A's of specific version. In B's docs, I want to leave a link to A's docs like this:
"See also A's documentation (v 1.0.1)"
Is this possible to pass the version variable to the URL? I tried using rst_prolog:
conf.py:
rst_prolog = '''
.. |a-ver| replace:: {ver}
'''.format(
ver=meta.__a_dep_version__,
)
index.rst:
A's version: |a-ver| # this produces the correct output
See also `framework docs <http://example.com/A/|a-ver|/index.html>`_.
but getting the URL https://example.com/A/%7Ca-ver%7C/+d/index.html after doc building.

You can use the sphinx.ext.extlinks extension for this.
Example
Sphinx configuration
extlinks = {'docs': ('http://example.org/A/%s/+d/index.html', 'framework docs ')}
Your documentation
:docs:`1.0.1`
.. Result -> framework docs 1.0.1
:docs:`documentation (1.2.3) <1.2.3>`
.. Result -> documentation (1.2.3)

Related

How to import Markdown with Sphinx and myst-parser into Readthedocs?

In my docs/source/conf.py I have this code:
extensions = [
"sphinx.ext.autodoc",
"myst_parser",
]
source_suffix = ['.rst', '.md']
All my files are in Markdown, not in reStructuredText.
On ReadTheDocs, the initial build was successful technically, only until the modules page was "not found" and the index page is completely blank.
My .readthedocs.yaml:
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# Optionally build your docs in additional formats such as PDF
formats: all
# Optionally set the version of Python and requirements required to build your docs
python:
version: "3.8"
install:
- method: pip
path: .
extra_requirements:
- docs
My setup.cfg contains this:
[options.extras_require]
docs =
sphinx
myst-parser
Of course, doing make clean html in docs/ works completely fine. Not sure why ReadTheDocs cannot properly link to the rest of the.md files from index.md.
I solved it. I checked the build logs, turns out I have some syntax errors (I did list[str] not List[str] with from typing import List)

How to use correct lang parameter?

I have a fresh Mediawiki installed into fresh UBUNTU 18 LTS... The ''SyntaxHighlight'' extension not works for Unix shell, lang="sh", lang="shell", lang="bash", ... no one is working. It is not at #Supported_languages, and there are no clues about how to install "Other markup".
At mediawiki.org/list there are no clues.
So, how to solve the problem? It is a config, env or syntax problem?
NOTES AND TESTS
Notes.
It is a corporative Wiki, no way to offer public URL... But it is a fresh, standard and controlled installation, all reproductive and standard.
The Wiki was configured with skin "Vector" and language "Brazilian Portuguese".
Tests.
Usage tests of mediawiki.org/Extension:SyntaxHighlight, the Python example.
1.1. With tag <syntaxhighlight>. Result: no highlight, same as <pre>.
1.2. With tag <source>. Result: no highlight, same as <pre>.
PHP example, fragment from wikipedia.org/PHP Syntax.
2.1. With tag <syntaxhighlight>. Result: no highlight, same as <pre>.
2.2. With tag <source>. Result: no highlight, same as <pre>.
The code fragments used in the tests:
def quickSort(arr):
less = []
pivotList = []
more = []
if len(arr) <= 1:
return arr
else:
pass
<title>PHP "Hello, World!" program</title>
<?php echo '<p>Hello World</p>'; ?>
MediaWiki Syntax highlighter used Pygments library, you should first download and install the extension:
Requirements
This version of the extension has been tested with Pygments 1.6, 2.0.2 and
MediaWiki 1.25 as of 2015-06-19. To get releases of this extension compatible
with earlier versions of MediaWiki, visit:
https://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi
Download
https://github.com/wikimedia/mediawiki-extensions-SyntaxHighlight_GeSHi/archive/master.tar.gz
Installation
Add this line to your LocalSettings.php:
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
By default, this extension will use a bundled copy of Pygments 2.0.2. If you
would like to use a different copy of the library, you can set
$wgPygmentizePath to point to the path to the 'pygmentize' binary.
Usage
On the wiki page, you can now use "source" elements:
<source lang="php">
<?php
v = "string"; // sample initialization
?>
html text
<?php
echo v; // end of php code
?>
</source>
Parameters
For details information of these parameters, see the documentation of Pygments'
HtmlFormatter at http://pygments.org/docs/formatters/#HtmlFormatter.
lang; Defines the language.
line; Corresponds to linenos="inline" option.
start; Corresponds to linenostart opion.
enclose; If set to "none", corresponds to the nowrap=1 option.
inline; Corresponds to the nowrap=1 option.
highlight; Corresponds to hl_lines option (comma separated).
Note
Pygments is generous about creating HTML elements: highlighting large blocks of
code can easily generate enough of them to crash a browser. As a guard, syntax
highlighting is turned off for code fragments larger than 100 kB.

How to set a BASE URL for sphinx documentation?

I have created documentation for my project using sphinx. the current endpoint for my documentation is /. My question is, how can i make my documentation follow a docs/<filename> pattern?
EX. <app.url>/docs/index.html
in my project's config.py i have:
DOCS_DIRECTORY = '/docs/'
Add this line in conf.py:
html_baseurl = '/docs/'
ref: sphinx doc
you should call sphinx-build -b html sourcedir builddir. See the Sphinx doc, page First Steps with Sphinx

Linking external documentation in Sphinx

I am trying to link from our project's extension documentation to the core documentation in Sphinx. I've tried intersphinx, but from what I see it only supports objects, while our documentation doesn't refer to objects, it's just plain .rst.
I've added
intersphinx_mapping = {
'project': ('http://link-to-readthedocs/index.html', None),
}
to conf.py and edited the link to :ref:\`Documentation\` and later :doc:\`Documentation\` . It didn't work.
The question:
How to link from one projects' documentation to another in Sphinx for plain .rst files (not objects)?
Edit: I've done make html, found my objects.inv, but now I guess I only have it locally? I'm not sure what I'm doing anymore, but when I try to check the object references, I get:
UserWarning: intersphinx inventory 'http://myproject.com/index.html/objects.inv' not fetchable due to <class 'urllib.error.HTTPError'>: HTTP Error 404: Not Found
'%s: %s' % (inv, err.__class__, err))
The first thing to fix here is the link you've included to the base URL of your project docs:
intersphinx_mapping = {
'project': ('http://link-to-readthedocs/index.html', None),
}
According to the intersphinx docs:
A dictionary mapping unique identifiers to a tuple (target, inventory). Each target is the base URI of a foreign Sphinx documentation set and can be a local path or an HTTP URI. The inventory indicates where the inventory file can be found: it can be None (at the same location as the base URI) or another local or HTTP URI.
Thus, the error is in having the index.html at the end of your target. It should instead look something like this:
intersphinx_mapping = {
'project': ('http://project.readthedocs.io/en/latest', None),
}
If desired, replace en with the preferred docs language, and latest with the preferred RtD built version of the docs.

Is the heuristic CocoaPods uses for the "pod try" command documented anywhere?

In CocoaPods v.0.29, the 'pod try' command was added (see http://blog.cocoapods.org/CocoaPods-0.29/). From the documentation (bold emphasis mine):
In other words the command automates the following steps:
Checkout the source of the Pod in a temporary directory.
Search for any project looking like a demo project using some simple heuristics.
Install any CocoaPods dependencies if needed by the located project.
Open the workspace/project in Xcode.
I've searched both Google and StackOverflow and have not been able to find any documentation about the specific heuristics that CocoaPods uses to locate a demo project. Is the process by which CocoaPods locates a demo project, and/or best practices for including a demo project and scheme documented anywhere? I am putting together a library which I hope to turn into a CocoaPod soon, and would like to ensure that my sample project will actually work correctly with CocoaPods.
Thank you for your time.
I was looking for this as well and the only thing I got was the source of the pod-try plugin:
# Picks a project or workspace suitable for the demo purposes in the
# given directory.
#
# To decide the project simple heuristics are used according to the name,
# if no project is found this method raises and `Informative` otherwise
# if more than one project is found the choice is presented to the user.
#
# #param [#to_s] dir
# The path where to look for projects.
#
# #return [String] The path of the project.
#
def pick_demo_project(dir)
projs = projects_in_dir(dir)
if projs.count == 0
raise Informative, 'Unable to find any project in the source files' \
" of the Pod: `#{dir}`"
elsif projs.count == 1
projs.first
elsif (workspaces = projs.grep(/(demo|example).*\.xcworkspace$/i)).count == 1
workspaces.first
elsif (projects = projs.grep(/demo|example/i)).count == 1
projects.first
else
message = 'Which project would you like to open'
selection_array = projs.map do |p|
Pathname.new(p).relative_path_from(dir).to_s
end
index = choose_from_array(selection_array, message)
projs[index]
end
end
I don't know Ruby, but seems that it gets the list of all XCode projects/workspaces (except the Pods project and the projects that have a sister workspace) and picks:
The only item if there's only one item found.
The only workspace that has "demo" or "example" in filename if there's only one such item found.
The only project that has "demo" or "example" in filename if there's only one such item found.
Nothing, but let's you choose from all the items found.
If somebody has corrections to this - they're welcomed, as I'm no Ruby guy.

Resources