ImportError messages when running "make html" when the source files are located in a different folder than sphinx's

102 views
Skip to first unread message

Sagiv Grupper

unread,
Apr 10, 2016, 7:01:26 AM4/10/16
to sphinx-users
Hi,
I configured Sphinx in a dedicated folder (using sphinx-quickstart), on my local machine - for example c:\Documentation.
My python code is located in another folder for instance c:\dev

I performed the following steps:
  1. From the Sphinx folder (Documentation), I ran: "sphinx-apidoc -o . c:\dev" command in order to create .rst files.
  2. Then I ran "make html"
I received lots of ImportError messages.
Html files were created in the _build folder but they contained partial data.

I also tried to edit conf.py file (sys.path.insert(0, "c:\\dev")) but it didn't help.

The only way that I managed to generate the documentation, was when I copied the source folder and located it under the Documentation folder.

What can be the problem?

Thanks for the help.

Sagiv



Peter Burdine

unread,
Apr 18, 2016, 7:42:19 PM4/18/16
to sphinx-users
I ran into the same issue.  The consensus I found was that it isn't supported.  If you run on UNIX-ish systems, you can use symlinks then it will be happy.  On Windows, you can kind of do the same thing,  Unfortunately, you need admin rights to make links on Windows, but you don't need admin rights to make junctions.  So we created junctions under our source directory to point to the actual contents elsewhere on the file system.  For example, we have some common source that is shared between documents so our structure looks something like:
root
  document1
   
...
    source
      common  
->  ..\..\common
  document2
   
....
    source
      common  
->  ..\..\common
  common
    files_common_to_document1_document



The links would be created with the command "mklink /j common ..\..\common".  Note that MS decided to reverse the parameters so they aren't compatible with UNIX.

Hope that helps.

--Peter

Peter Burdine

unread,
Apr 18, 2016, 7:42:20 PM4/18/16
to sphinx-users
From my research it doesn't appear that this works in Sphinx.  What you can do though is create links or junctions under your source directory to make it look like source files are in a subdirectory of your project.  That will allow Sphinx to consume them.  You have to have admin rights in Windows to make a link, but not a junction, so that may be your best bet.  Be aware though, that SVN doesn't support links/junctions on Windows, so if you use SVN, you need to be careful not to check in the junction.  Instead check in the directory where your source files are.  The command on windows is "mklink /j target source".  This is the method I used for common files on Windows systems.


On Sunday, April 10, 2016 at 4:01:26 AM UTC-7, Sagiv Grupper wrote:
Reply all
Reply to author
Forward
0 new messages