Extranet access to PyDoc documents

Recently, I was working on a team project, which produced a large number of functions and classes, which were difficult to find and use by the team. It was difficult to find the most native Python code document format, so I came up with the idea of making a standard API document.

Through Bing, Baidu and Google, the general idea was finally determined:

Project documentation is generated automatically in the cloud using Python native PyDoc

  • The environment

    1. Ali Cloud ECS 1 core 2GB CentOS7
    2. Anaconda3 – python3.6 version
    3. Project source documents that follow the PEP8 style specification
  • The configuration process

    1. Try using PyDoc -w

      to generate offline document locally: only one PY file can be generated in HTML document, the document calling package has page link but no corresponding HTML file, you need to manually generate or analyze the structure of the web page to write an automatic generation program

    2. Pydoc -p port is used to start the web service of the specified port. The local view is successful with detailed content and strong link correlation

    3. Use FileZilla Client to pass the project file to the specified non-root folder. Run the $pydoc -p port command in the project folder path of the ECS to start the Web server. An extranet attempt failed. Procedure

    4. After excluding the influence of Ali Cloud security group, the problem was identified as pyDoc itself.

    5. Use the find command in the anaconda3 path of ECS to find the pydoc.py file

      . $find -name pydoc. Py. / lib/python3.6 / pydoc py. / PKGS/python - 3.6.4 radar echoes captured... ./pkgs/..............................Copy the code
    6. Found, and then use vim view/modify pydoc. Py, here can be directly on the local computer to view, and changes in the ECS, borrowed from a big record blog directly in the pydoc. Py finds the host field

      Vim is used in normal mode/hostTo find the

      Self. host = “localhost”; self.host = “localhost”; self.host = “localhost”;

    7. External network attempts to access the ECS public IP address :port succeeds.

    8. Create a new shell with $screen -r pydoc. Enter $pyDoc -p port to start the Web service.

    9. Ctrl+ A and press D to exit the new shell window

      $logout Logs out the SSH connection

    This completes the configuration.