How to access Sphinx-generated search index through static JavaScript files? - python-sphinx

When Sphinx generates documentation, it also generates special searchindex.js file, which contains all of the documentation items. How to acess it from a JS script placed in _static?

In _static/myfile.js, you can reference the path from the root of the built docs, for example, /searchindex.js.

Related

Ignore document folders in URL path of sphinx project

I'm constructing a Sphinx documentation and would like to place my .rst files in an organized folder structure. However, for my actual URL path I would like to not have these sub folders be included in the URL - rather, I would like to have a simple URL path as below:
[domain-url.com]/[file-name]
Is this possible to configure?

Is there a proper path for storing images (Theme and Uploads) in Laravel?

I'm relatively new to Laravel - building a basic website with it - and I'm unclear as to where I'm suppose to store images.
My instinct said /resources/images but that path doesn't exist like /js and /css do.
I read that /storage/app/public/images could be, but the answers I'm finding are inconclusive.
I understand the local may differ if they were uploaded through a GUI by an end-user vs by a developer who is creating a theme / template.
I'd like a citation to official documentation assuming one exists. Thank you!
I unintentionally discovered this Laravel official documentation which explains the purpose of each directory. In that it states the following:
This (/public) directory also houses your assets such as images, JavaScript, and CSS.
Based on the next quote it's implied the above is referring to images uploaded by the developer for the front end. Whereas the following explicitely states it's for user-generated files:
The /storage/app/public directory may be used to store user-generated files, such as profile avatars, that should be publicly accessible.
Earlier in the documentation is makes a subtle but, presumably, essential note:
By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public.
#techcyclist rightly referenced more official documentation about how to reference these in their respective locations. Such as files in the /storage this way, and the public directory this way. It also mentions advanced options for storage such as Amazon S3 under "Specifying a Disk".
Usually images are stored in public folder and you can easily access then with /img/somepic.jpg from anywhere in your project. Also you can store them in storage/images but then you need to use function for relative path to storage.
image does not exist in resources folder it exists in public folder
try like this, it will pick public folder default.
{{url('images/image_name')}}

Middleman - How to change the paths for generated html files?

I'm building a website using Middleman. There are source files placed like the following.
source/index.html.md
source/errors/404.html
source/docs/foo.html.md
source/docs/bar.html.md
By default, when I build static html files, the generated files are placed following to the original directory structure (with directory indexes).
build/index.html
build/errors/404/index.html
build/docs/foo/index.html
build/docs/bar/index.html
However, I want all html files to be served directly under /, so that they can be accessed like http://example.com/foo/ and http://example.com/404/.
How do you change the paths for generated html files?
You can use proxies to create duplicate pages, and then ignore the original pages.
https://middlemanapp.com/basics/dynamic-pages/
But the simplest way is, of course, to adjust the source structure to match the desired structure.
I think this part of Middleman doc could help you .
All you need is to activate directory indexes and configure it properly, and it should work.

External Relative Link in Sphinx toctree directive

I'm using Sphinx to build my documentation. I'm using other tool for API reference. I have my docs in a directory and the API reference in directory name api inside of it.
I want to have a link from the documentation to the API reference. I'm able to add a link to my toctree link so:
.. toctree::
:maxdepth: 1
starting
glossary
main-use-case-flow
API Reference <http://www.example.com/lib/ios/0.1.0/api/>
The problem is I don't want to put a full path, I want to put just the relative path api/
How can I put a link to external resource using relative path and not absolute path?
I found one of the hackiest ways possible to do this. Basically Sphinx allows either a path to a document or an absolute path that requires http://. It turns out all they do to validate your link is look for literally http://.
*WARNING: toctree contains reference to nonexisting document u'downloads'*
Downloads <../downloads>
But if you do:
Downloads <../downloads#http://>
No warning! This does mean however that when the user clicks on your link, it inserts the http:// fragment or named anchor to your page link. If this is not a valid named anchor in your html, it will do nothing to your page (unless your page has some javascript that does something with the named anchor).
In the current version of Sphinx you can just put
.. toctree::
Title <http://LINK>
and it will work.
I encountered this problem when I tried to add links to (generated) javadocs to my toctree.
My solution was to create a phony index.rst in the appropriate location within my source tree to satisfy the requirements of toctree. I discovered the phony index.rst file must contain a title, so my file looked like this:
=======================
Java API (All Packages)
=======================
When you run make, this file gets copied into your build directory, _build/html (or whatever).
And then simply replace it with the real file after reStructuredText processing.
The following syntax works for me:
`Page Title <../relative/path.html>`

Can the sitemap files be in a folder if the sitemapindex is in the root path?

I want to have a sitemap structure where the sitempasindex file is located in the root path (example.com/sitemaps.xml) and it references several sitemap[n].xml files located in a folder (example.com/static/sitemap1.xml). Those sitemap[n].xml files link to webpages that are in the rooth path (like example.com/helloworld.html).
Is that posible? I'm asking because I know that if the sitemap.xml file is placed within a folder, it can only contain webpages that are under that folder.
Thanks!
I believe you easily have
example.com/sitemap-index.xml
point to e.g.
example.com/sub1/sitemap.xml
and
example.com/sub2/sitemap.xml
however each sitemap.xml should only contains URLs within each their subfolder. (From your question, it seems you have those sitemap.xml files link to paths in root. I doubt that works, but you could try run a small test and submit to Google. If no errors then...)
The location of a Sitemap file determines the set of URLs that can be included in that Sitemap. A Sitemap file located at http://example.com/catalog/sitemap.xml can include any URLs starting with http://example.com/catalog/ but can not include URLs starting with http://example.com/images/.
From google perspective, they should be available on main root of the website. http://example.com/sitemap.xml, When you submit it through the subdir in webmaster tool "http://example.com/catalog/sitemap.xml" google won't crawl it and always showing us pending index status.

Resources