Python Forum
Pydoc documentation doesnt work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pydoc documentation doesnt work
#1
I keep trying to make a html documentation file with pydoc .

I run my code in Python IDLE Shell and then use this:

import <your module name> as name:
import pydoc
pydoc.writeDoc(name)
But it doesn't work at all. I don't get a .html documentation file of my program.
Could someone help?

I have also tried this:

pydoc -w myModule.py
in IDLE and it also did not work.
Reply
#2
Try
Output:
pydoc -w myModule
in an ordinary terminal (not in the python console). Don't include the ".py" suffix in the module's name.
Reply
#3
(Dec-12-2019, 11:26 PM)Gribouillis Wrote: Try
Output:
pydoc -w myModule
in an ordinary terminal (not in the python console). Don't include the ".py" suffix in the module's name.

Ive tried it in in cmd and also in Python terminal. It didnt work.
Reply
#4
What happens if you type in a Cmd terminal
Output:
pydoc -b
?
Reply
#5
(Dec-13-2019, 06:59 AM)Gribouillis Wrote: What happens if you type in a Cmd terminal
Output:
pydoc -b
?

I have figured it out. It works now. Thank you for your help aswell and for your time.

The problem for me was that I would open the file as Edit With IDLE (by clicking on the .py file with right mouse click), but when I tried opening the program using File->Open in IDLE Shell it seemed to work fine.
Reply
#6
I'm glad you figured it out. For others who might be interested:

PyDoc reads and generates documentation based on the docstrings you have written in your code. Docstrings are just comments enclosed in triple quotes that tell others what the code does, what the parameters are or what the function returns.
I suggest two ways to do that:

One way to generate an HTML documentation from inside your code editor, is to just import pydoc and at the end use pydoc.writedoc('name_of_my_module') . This generates name_of_my_module.html in the same directory.

import pydoc

def add(x, y):
    """
    Params:
      x and b are numbers (int or float)
    Returns: 
      the sum of x and y.
    """
    return x + y

pydoc.writedoc('my_module')
Alternatively, you can remove the import pydoc and the last line and instead use command line by using python -m pydoc -w my_module

To learn more you can read the following article: https://pythonology.eu/how-to-use-pydoc-...in-python/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 233 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  pip install requests doesnt work misodca 8 5,603 Jul-07-2023, 08:04 AM
Last Post: zyple
  Ldap3 Python print(conn.entries) doesnt work ilknurg 15 5,572 Dec-28-2022, 11:22 AM
Last Post: shad
  pip install pystyle doesnt work person_probably 2 2,004 Sep-23-2022, 02:59 PM
Last Post: person_probably
  Why doesnt chunk generation work? LotosProgramer 1 1,909 Apr-02-2022, 08:25 AM
Last Post: deanhystad
  if conditions in the for indentation doesnt work ? Sutsro 6 3,829 Jun-15-2021, 11:45 PM
Last Post: bowlofred
  how to suppress not to display the package contents from pydoc! maiya 3 2,437 Mar-19-2021, 03:41 AM
Last Post: bowlofred
  I have two Same Code but One of them Doesnt Work beginner721 6 3,005 Jan-22-2021, 10:56 PM
Last Post: beginner721
  code doesnt return anything ofrihemo 3 1,988 Jun-30-2020, 05:14 PM
Last Post: ofrihemo
  BEGINNER: My calculator doesnt work iskov 5 3,131 Oct-09-2019, 07:45 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020