Skip to content

Modernize pydoc to use better HTML and separate CSS #54925

Closed

Description

@rhettinger
BPO 10716
Nosy @birkenfeld, @rhettinger, @terryjreedy, @abalkin, @aroberge, @ezio-melotti, @merwok, @bitdancer, @ambv, @berkerpeksag, @serhiy-storchaka, @tritium21, @JulienPalard, @Mariatta, @tirkarthi, @brickman1444
PRs
  • bpo-10716: Migrating pydoc to html5. #28651
  • Files
  • css_v2.diff: css support in the new pydoc pages.
  • css_v3.diff: css support for the new pydoc pages.
  • css_master.diff
  • Screen Shot 2019-03-24 at 10.58.33 am.png: pydoc with updated CSS and bootstrap
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2010-12-16.09:25:37.954>
    labels = ['type-feature', 'library', '3.11']
    title = 'Modernize pydoc to use better HTML and separate CSS'
    updated_at = <Date 2021-10-09.07:36:58.565>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2021-10-09.07:36:58.565>
    actor = 'mdk'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2010-12-16.09:25:37.954>
    creator = 'rhettinger'
    dependencies = []
    files = ['20216', '20236', '48230', '48231']
    hgrepos = []
    issue_num = 10716
    keywords = ['patch']
    message_count = 57.0
    messages = ['124119', '124144', '124147', '124157', '124158', '124159', '124162', '124164', '124176', '124177', '124179', '124181', '124195', '124306', '124825', '124857', '124858', '124863', '125033', '125049', '125111', '125113', '125122', '127542', '130629', '165401', '165406', '183304', '183319', '234936', '234940', '234941', '234942', '236962', '246917', '246920', '277934', '278084', '278089', '278090', '278098', '278119', '278123', '278126', '278127', '278166', '278191', '338700', '338703', '338716', '338717', '397265', '397353', '397354', '402962', '403397', '403520']
    nosy_count = 21.0
    nosy_names = ['georg.brandl', 'rhettinger', 'terry.reedy', 'belopolsky', 'ron_adam', 'donmez', 'aroberge', 'ezio.melotti', 'eric.araujo', 'r.david.murray', 'PeterLovett', 'lukasz.langa', 'berker.peksag', 'serhiy.storchaka', 'tritium', 'azsorkin', 'Fr\xc3\xa9d\xc3\xa9ric Jolliton', 'mdk', 'Mariatta', 'xtreak', 'brickman1444']
    pr_nums = ['28651']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue10716'
    versions = ['Python 3.11']

    Activity

    1. rhettinger commented on Dec 16, 2010

      @rhettinger
      ContributorAuthor

      This is a straight-forward project.

      Pydoc currently generated 1990's style html which mixes content and presentation, making it very difficult for users to customize the appearance of the output.

      It is full of html like:

      <table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
      <tr bgcolor="%s">
      <td valign=bottom> <br>
      <font color="%s" face="helvetica, arial"> <br>%s</font></td

      <td align=right valign=bottom
      <font color="%s" face="helvetica, arial">%s</font></td></tr></table>
      ''' % (bgcol, fgcol, title, fgcol, extras or ' ')

          def section(self, title, fgcol, bgcol, contents, width=6,
                      prelude='', marginalia=None, gap='&nbsp;'):
              """Format a section with a heading."""
              if marginalia is None:
                  marginalia = '<tt>' + '&nbsp;' * width + '</tt>'
              result = '''<p>
      <table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
      <tr bgcolor="%s">
      <td colspan=3 valign=bottom>&nbsp;<br>
      <font color="%s" face="helvetica, arial">%s</font></td></tr>
          ''' % (bgcol, fgcol, title)
              if prelude:
                  result = result + '''
      <tr bgcolor="%s"><td rowspan=2>%s</td>
      <td colspan=2>%s</td></tr>
      <tr><td>%s</td>''' % (bgcol, marginalia, prelude, gap)

      Please convert it to simple, validated HTML with the formatting moved to a simple, validated default style sheet. Liberally apply div/span elements with class/id attributes as necessary.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Dec 16, 2010
    3. self-assigned this
      on Dec 16, 2010
    4. abalkin commented on Dec 16, 2010

      @abalkin
      Member

      I believe Ron has done something along these lines already. See bpo-2001. Committed css file is empty, (see r86971) but I am adding Ron to "nosy" in case he has something in the pipeline.

    5. abalkin commented on Dec 16, 2010

      @abalkin
      Member

      See also the calendar module for an example of a "modern" html.

    6. ronadam commented on Dec 16, 2010

      ronadammannequin
      Mannequin

      I uploaded the css file I used in an experimental version of pydoc. It may give some useful starting values.

      Before this is done, the old server code should be removed (also for 3.3). (another issue?) There are two files in the tools/scripts directory that may need attention as well. pydocgui.pyw and pydoc3.

    7. merwok commented on Dec 16, 2010

      @merwok
      Member

      Those two scripts are just three-liners pydoc launchers.

      I disagree about the CSS reset. Default values and user-set values have a reason for being there, and I share the viewpoint that they should not be reset.

    8. rhettinger commented on Dec 16, 2010

      @rhettinger
      ContributorAuthor

      I'm looking for a deeper fix, all the in-line styling replaced by a stylesheet. Can you guys work together on bring this to fruition?

    9. ronadam commented on Dec 16, 2010

      ronadammannequin
      Mannequin

      Eric, most of what's in that file is what I figured out by trial and error in order to get it to work on the different browsers at that time. (about 3 years ago.) You are probably more experienced with css than I am, so you are more than welcome to update and change anything in there. :-)

      What do you think about starting with a set of static html pages to get the css and html to work nice, and then only after that is done, edit pydoc to generate those pages. That should get us mostly there, and simplify what needs to be done in pydoc.

    10. rhettinger commented on Dec 16, 2010

      @rhettinger
      ContributorAuthor

      A good procedure is to start afresh with an empty, embedded style sheet and replace the html styling attributes one at a time, while keeping the overall look and feel the same. At the end of the process the embedded style sheet can be converted to external.

    11. ronadam commented on Dec 17, 2010

      ronadammannequin
      Mannequin

      I think that's how I ended up with the style sheet I uploaded. It works, but it can be a slow process.

      Another factor is the pydoc server will reread an external style sheet on browser refreshes. So you can see the results of style sheet changes without restarting pydoc. If it's embedded, you need to edit the program and restart everything each time.

      I was thinking that I may still be able to make a set of static html files that go along with that style sheet. Then we can adjust the css class names and make other changes, then use that as a guide for replacing the html.

      Eric, what do you think?

    12. rhettinger commented on Dec 17, 2010

      @rhettinger
      ContributorAuthor

      The uploaded stylestyle is *much* bigger than I expected. There should be no more than a one-to-one correspondence. With inheritance, perhaps even fewer entries.

    13. ronadam commented on Dec 17, 2010

      ronadammannequin
      Mannequin

      Ok, I just looked at them again, I didn't remember how different it was. They probably won't be much help other than maybe seeing how some things could be done. Here's a zip file of some saved pages, so you can take a look.

    14. ezio-melotti commented on Dec 17, 2010

      @ezio-melotti
      Member

      The CSS also has a validation error, some warnings and could be written better IMHO (specifically I don't like the placement of the {}).

      I also don't believe that extensive CSS resets are useful -- they usually just lead to lot of redefining. I usually limit myself to * { margin: 0; padding: 0; } and possibly specify specific values when necessary. Minor differences with different browsers can be perfectly fine in lot of cases.

    15. 44 remaining items

    16. rhettinger commented on Mar 23, 2019

      @rhettinger
      ContributorAuthor

      I've found the HTML to be useful (-w mode, not running a server) for generating quick documentation (much lighter weight commitment than using sphinx). I show this in my intro classes and the engineers are usually impressed with it.

      This is really easy and requires neither configuration files or reST markup:

          $ python -m pydoc -w statistics
          wrote statistics.html

      So, my vote it to keep it.

      I would still like modern HTML 5 with CSS however.

    17. aroberge commented on Mar 23, 2019

      arobergemannequin
      Mannequin

      On Sat, Mar 23, 2019 at 6:27 PM Raymond Hettinger <report@bugs.python.org>
      wrote:

      Raymond Hettinger <raymond.hettinger@gmail.com> added the comment:

      I've found the HTML to be useful (-w mode, not running a server) for
      generating quick documentation (much lighter weight commitment than using
      sphinx). I show this in my intro classes and the engineers are usually
      impressed with it.

      This is really easy and requires neither configuration files or reST
      markup:

      $ python -m pydoc -w statistics
      wrote statistics.html
      

      So, my vote it to keep it.

      I would still like modern HTML 5 with CSS however.

      I submitted code to do this in January 2015 on the bug tracker but, except
      for some interest by a single person, my submission was essentially
      ignored. I do not claim it is perfect, but I thought it was a significant
      improvement as it did use HTML 5 with CSS.

      André Roberge

      ----------


      Python tracker <report@bugs.python.org>
      <https://bugs.python.org/issue10716\>


    18. tirkarthi commented on Mar 24, 2019

      @tirkarthi
      Member

      I stumbled upon this issue because I think this is a potential improvement. One of the reasons I don't use it is due to the outdated UI but since it also generates HTML doc for installed packages in a virtual environment I find this to be a useful feature like rdoc (ruby), rustdoc (rust) and are actively maintained helping documentation of third party packages too for local reference.

      I have less knowledge about CSS but I tried updating css_v3.diff with master and added boostrap.css from CDN to pydoc which adds spacing along with improving layout and font. Attached is a screenshot that is looks better with the CSS patch and bootstrap. Including bootstrap is not lightweight option in the Python distribution but can be seen as a proof of improvement.

    19. tirkarthi commented on Mar 24, 2019

      @tirkarthi
      Member
    20. brickman1444 commented on Jul 11, 2021

      brickman1444mannequin
      Mannequin

      Hey all, I'd like to note my interest in this issue getting addressed. I have a use case where I'd like to generate documentation for a module and using non-core modules to do that requires some approval that I would like to avoid.

      I understand there are other more important issues but this issue has had a patch waiting for review for ten years. Can we move this forward somehow?

    21. merwok commented on Jul 12, 2021

      @merwok
      Member

      Someone would need to take the patch, apply it to current main branch, fix issues and open a PR.

    22. added
      3.11only security fixes
      and removed on Jul 12, 2021
    23. merwok commented on Jul 12, 2021

      @merwok
      Member

      On second thought, this issue is not purely programming, but also has a UI component. Better HTML and separated CSS would be good, but before that I think we’d need someone with design chops to mock up a better page layout and style (better than big coloured rectangles!), then I think have a discussion on python-dev (not to discuss all details in committee, but to validate the overall change).

    24. JulienPalard commented on Sep 30, 2021

      @JulienPalard
      Member

      Tried myself at it.

      I'm not a front-end guy, fasten your seatbelts.

      I tried to keep it minimal, but after some work the change is not that small, I focused on the HTML modernization only, not the design (to try to land at least a first step toward modernization).

    25. JulienPalard commented on Oct 7, 2021

      @JulienPalard
      Member

      Does someone want to review #28651?

    26. JulienPalard commented on Oct 9, 2021

      @JulienPalard
      Member

      New changeset c91b6f5 by Julien Palard in branch 'main':
      bpo-10716: Migrating pydoc to html5. (GH-28651)
      c91b6f5

    27. transferred this issue fromon Apr 10, 2022
    28. furkanonder commented on May 11, 2023

      @furkanonder
      Contributor

      @JulienPalard The issue seems to have been solved. I think we can issue the problem.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.11only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions