Check if Sphinx doc called the script

前端 未结 4 2182
予麋鹿
予麋鹿 2021-01-18 15:41

I am currently trying to generate sphinx documentation for scripts which use the ArcGIS arcpy library.

I am running into an issue when sphinx tries to run the scrip

4条回答
  •  忘掉有多难
    2021-01-18 16:12

    If your project is importing sphinx (in my case a sphinx extension), the following may also work for you

    import os
    import sys
    if os.path.basename(sys.argv[0]) == "sphinx-build":
        # code for when sphinx is running
    else:
        # code for regular application
    

    I'm not sure if that will work on Windows or if it should be something like

    if os.path.basename(sys.argv[0]) in ["sphinx-build", "sphinx-build.exe"]:
    

提交回复
热议问题