absolute path from Root to import image

408 views
Skip to first unread message

fabien leboeuf

unread,
May 6, 2016, 7:25:34 PM5/6/16
to sphinx-users
Hi


I would like to gather all my images in the same folder. ( media) 

 
how can i import an image in  my rst 


I would like to use this kind of directive

.. image:: ROOT/media/image.png

instead of using am relative path from my rst

regards

Fabien
 

Peter Burdine

unread,
May 9, 2016, 6:26:53 PM5/9/16
to sphinx-users
I don't think this works.  See the thread here about documents outside of the "root" directory.

https://groups.google.com/d/msg/sphinx-users/7k6YJ7-t5BY/32h7NWegHgAJ
"ImportError messages when running "make html" when the source files are located in a different folder than sphinx's"

--Peter

gilberto dos santos alves

unread,
May 10, 2016, 5:28:47 PM5/10/16
to sphinx...@googlegroups.com
if your environment is windows use comand:

mklink /D your-name c:\your-real-path\and-dir

C:\d16down\doc16>dir
 O volume na unidade C é dc7600_C
 O Número de Série do Volume é 5C39-116C

 Pasta de C:\d16down\doc16

10/05/2016  17:55    <DIR>          .
10/05/2016  17:55    <DIR>          ..
10/05/2016  15:34    <DIR>          build
10/05/2016  17:55    <SYMLINKD>     limage [c:\d16down]
10/05/2016  15:11             7.753 make.bat
10/05/2016  15:11             8.097 Makefile
10/05/2016  17:57    <DIR>          source

in this real example my-images are inside c:\d16down

and my index.rst inside source dir is:

.. image uri path documentation master file, created by

Documentação path uri para imagens
==================================

Conteúdo:

.. toctree::
   :maxdepth: 2

   p1
   p2
   p3

and my p3.rst is like:

.. imagens com exemplos do comando mklink


imagens fora do diretorio raiz sphinx
=====================================

Neste tópico demonstramos o uso das imagens de um diretorio virtual.
Que foi criado com o comando


    mklink /D limage c:\d16down
  
Diversas imagens podem ser usadas, vejamos a 5a ima05:
  
.. image:: ..\limage\ima05.jpg
  
Nesse páragrafo vamos incluir a 2a ima06:
  
.. image:: ..\limage\ima06.png

see that ima05 and 06 leave in c:\d16down but from perspective of sphinx build
they are inside sphinx root directory doc16

C:\d16down>dir ima*
 O volume na unidade C é dc7600_C
 O Número de Série do Volume é 5C39-116C

 Pasta de C:\d16down

10/05/2016  18:06            77.062 ima05.jpg
10/05/2016  18:04           133.067 ima06.png


if you use linux or mac use comand ln -S   (create a symbolic directory).

.ps when you publish your build-directory html for http server be sure that all things are correct handled by your confs.

for reference you could use on .. image:: http://some-host/and-uri-of-image.png






--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To post to this group, send email to sphinx...@googlegroups.com.
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.



--
gilberto dos santos alves
+55(11)9-8646-5049
sao paulo - sp - brasil




Reply all
Reply to author
Forward
0 new messages