B
    ž3Rch
  ã               @   s.   d dl Zd dlmZ i g fdd„Zdd„ ZdS )é    N)Únodesc                s  d}d‰ ‡ fdd„}d| }	d||f  }
}|  d¡}||ƒs\|  d¡d }	d	||f  }
}||ƒsÔ|d }d |d
d… ¡}d||f }||ƒr d||f }
n4d	||f }||ƒrÔd |dd
… ¡}	d|||f }
||ƒrötj||	fd|
i|—Ž}nt ||¡}|gg fS )aÊ  
    Role `:api:` bridges generated API documentation by tool like EpyDoc
    with Sphinx Python Documentation Generator.

    Other tools, other than EpyDoc, can be easily supported as well.

    First generate the documentation to be referenced, i.e. with EpyDoc::

        $ mkdir -p doc/_build/html/api
        $ epydoc -o doc/_build/html/api ...

    Next step is to generate documentation with Sphinx::

        $ sphinx-build doc doc/_build/html

    Úapiz_build/html/c                s   t j ˆ |  ¡S )N)ÚosÚpathÚexists)Úf)Úprefix© ú$share/RDKit/Docs/Book/exts/extapi.pyÚ<lambda>-   ó    zapi_role.<locals>.<lambda>z%sz%s/%s-module.htmlÚ.éÿÿÿÿz%s/%s-class.htmlNz%s#%séþÿÿÿz%s/%s-class.html#%sZrefuri)ÚsplitÚjoinr   Z	referenceÚliteral)ZroleZrawtextÚtextÚlinenoZinlinerZoptionsZcontentZbasedirr   ÚnameZuriÚfileZchunksÚmethodZfprefixZnoder	   )r   r
   Úapi_role   s.    
r   c             C   s   |   dt¡ d S )Nr   )Zadd_roler   )Zappr	   r	   r
   ÚsetupP   s    r   )Úos.pathr   Zdocutilsr   r   r   r	   r	   r	   r
   Ú<module>   s   6