9

I documented some functions using autodoc. Locally it works well. When I commit to GitHub, the documentation is built on ReadTheDocs, but there are no functions that I documented with "automodule".

I added in my conf.py:

import mock

MOCK_MODULES = ['numpy', 'scipy']
for mod_name in MOCK_MODULES:
   sys.modules[mod_name] = mock.Mock() 

But it does not help.

Could this be related to the fact that I use my own C library? (I have my .c file that I compile to get .so)

Cœur
  • 37,241
  • 25
  • 195
  • 267
natalia
  • 309
  • 2
  • 11
  • Did you check the log? If you go to your project's _Build_ tab, you can see the logs of what's happened. For example: https://readthedocs.org/builds/beaver/1529001/. Check that and post what it says. – kirbyfan64sos Jul 17 '14 at 16:14
  • @kirbyfan64sos, I have this in _Build_ tab: https://readthedocs.org/builds/icclim/1528989/ – natalia Jul 17 '14 at 16:40

1 Answers1

5

After reading you source files and the log file, I gathered two things:

  1. Why did you comment out the line sys.path.insert(os.path.abspath('../..')) in conf.py? If you read the logs, RTD can't find your modules. That line would put in the proper path.

  2. You need to put your C library as a mock module, too.

kirbyfan64sos
  • 10,377
  • 6
  • 54
  • 75
  • I decommented the line with abspath('../..'). But how to put my C library as a mock module? I tried like this: MOCK_MODULES = ['numpy', 'scipy', 'ctypes', 'numpy.ctypeslib', 'ctypes.cdll', 'libC', 'libC.c', 'libC.so']. But it still does not work... – natalia Jul 18 '14 at 07:39
  • I tried also to put in my conf.py before the MOCK_MODULES line this: import ctypes libraryC = ctypes.cdll.LoadLibrary('../../libC.so'), and after I added in MOCK_MODULES: 'libraryC'. Does not work... – natalia Jul 18 '14 at 07:50
  • Ok, it is OK now! It work percectly! (The problem was just that I was not very attentive, I forgot to add certain modules (like netCDF4 and netcdftime) in MOCK_MODULES list) Thanks a lot, @kirbyfan64sos! Btw, to load my C library, do I need always to commit my **.so** file? Because I usually put **.so** files in .gitignore. – natalia Jul 18 '14 at 14:50
  • @natalia: What do you mean? RTD won't import ANY C libraries, but if you're just using the library through ctypes or the like, you'll be fine. It's generally frowned upon to upload binary files to Git. So...just leave it in your .gitignore. – kirbyfan64sos Jul 18 '14 at 18:14