o
    þ0GfÎ  ã                   @   s2   d Z ddlZddlmZ dZdd„ Zd	dd„ZdS )
zj
Provides a function to open the system browser to either search or go directly
to a function's reference
é    N)Ú	urlencodezhttps://www.statsmodels.org/c                 C   s°   t }|r	|d7 }n|d7 }| du r|S t| tƒr*|d7 }|td| iƒ7 }|d7 }|S z"| } | j}| j}| d¡s<tdƒ‚|d	7 }||d
 | d 7 }W |S  tyW   tdƒ‚w )zw
    Parse inputs and return a correctly formatted URL or raises ValueError
    if the input is not understandable
    zstable/zdevel/Nzsearch.html?Úqz &check_keywords=yes&area=defaultzstatsmodels.z!Function must be from statsmodelsz
generated/Ú.z.htmlzInput not understood)	ÚBASE_URLÚ
isinstanceÚstrr   Ú__name__Ú
__module__Ú
startswithÚ
ValueErrorÚAttributeError)ÚfuncÚstableZurlZ	func_nameZfunc_module© r   ú5lib/python3.10/site-packages/statsmodels/tools/web.pyÚ_generate_url   s.   

ö
þÿr   c                 C   s4   ddl m} d|vr|n|}t| |ƒ}t |¡ dS )ay  
    Opens a browser and displays online documentation

    Parameters
    ----------
    func : {str, callable}
        Either a string to search the documentation or a function
    stable : bool
        Flag indicating whether to use the stable documentation (True) or
        the development documentation (False).  If not provided, opens
        the stable documentation if the current version of statsmodels is a
        release

    Examples
    --------
    >>> import statsmodels.api as sm

    Documentation site

    >>> sm.webdoc()

    Search for glm in docs

    >>> sm.webdoc('glm')

    Go to current generated help for OLS

    >>> sm.webdoc(sm.OLS, stable=False)

    Notes
    -----
    By default, open stable documentation if the current version of
    statsmodels is a release.  Otherwise opens the development documentation.

    Uses the default system browser.
    r   )Ú__version__ZdevN)Zstatsmodels._versionr   r   Ú
webbrowserÚopen)r   r   r   Zurl_or_errorr   r   r   Úwebdoc*   s
   %

r   )NN)Ú__doc__r   Zurllib.parser   r   r   r   r   r   r   r   Ú<module>   s    