@@ -762,6 +762,21 @@ def rc_params(fail_on_error=False):
762762
763763# this is the instance used by the matplotlib classes
764764rcParams = rc_params ()
765+
766+ if rcParams ['examples.directory' ]:
767+ # paths that are intended to be relative to matplotlib_fname()
768+ # are allowed for the examples.directory parameter.
769+ # However, we will need to fully qualify the path because
770+ # Sphinx requires absolute paths.
771+ if not os .path .isabs (rcParams ['examples.directory' ]):
772+ _basedir , _fname = os .path .split (matplotlib_fname ())
773+ # Sometimes matplotlib_fname() can return relative paths,
774+ # Also, using realpath() guarentees that Sphinx will use
775+ # the same path that matplotlib sees (in case of weird symlinks).
776+ _basedir = os .path .realpath (_basedir )
777+ _fullpath = os .path .join (_basedir , rcParams ['examples.directory' ])
778+ rcParams ['examples.directory' ] = _fullpath
779+
765780rcParamsOrig = rcParams .copy ()
766781
767782rcParamsDefault = RcParams ([ (key , default ) for key , (default , converter ) in \
@@ -770,6 +785,8 @@ def rc_params(fail_on_error=False):
770785rcParams ['ps.usedistiller' ] = checkdep_ps_distiller (rcParams ['ps.usedistiller' ])
771786rcParams ['text.usetex' ] = checkdep_usetex (rcParams ['text.usetex' ])
772787
788+
789+
773790def rc (group , ** kwargs ):
774791 """
775792 Set the current rc params. Group is the grouping for the rc, eg.
0 commit comments