cpython icon indicating copy to clipboard operation
cpython copied to clipboard

Reorganize `os.path` documentation

Open picnixz opened this issue 10 months ago • 8 comments

The os.path documentation is alphabetically sorted. That's great because it's easy to find a function. However, this also means that functions shouldn't reference other functions documented later as the reader may not have been aware of them before.

An alternative is to reorganize the documentation page so that we put at the top the most used functions such as os.path.join. The latter caused a bit of confusion in gh-130527, where neither the OP nor me remembered that os.path.join("/a", "/b") == "/b".

If reorganizing the documentation is not preferred, we should at least add .. seealso:: directives and clickable links so that any function mentioned but not yet documented at the time of reading can be easily looked up.

  • os.path.abspath contains a reference to os.path.join without a link.
  • os.path.isabs could backlink to os.path.abspath.
  • os.path.split mentions os.path.join but as it's far away, we could backlink it.
  • os.path.join mentions "If a segment is an absolute path (which on Windows requires both a drive and a root), then all previous segments are ignored and joining continues from the absolute path segment.". We should add an example as it would be more explicit and teaching (e.g., os.path.join("/home/foo", "/home/bar") == "/home/bar".

Linked PRs

  • gh-130557
  • gh-131872
  • gh-132408
  • gh-142800
  • gh-142801

picnixz avatar Feb 25 '25 10:02 picnixz

I think seealso is probably the least disruptive to start with?

A

AA-Turner avatar Feb 25 '25 10:02 AA-Turner

To me it's indeed the case. I know that we have Ctrl+F to find in the page, but I also know people that are happy when it's alphabetically organized. I'll quickly check which function needs cross-ref with seealso.

picnixz avatar Feb 25 '25 10:02 picnixz

Ok, there's not much content to update. I've written down what needs to be done (roughly), maybe there are other places that could be improved. I'll stil mark this one as easy.

picnixz avatar Feb 25 '25 10:02 picnixz

Maybe split the docs into lexical functions (split(), join(), etc) vs I/O functions (exists(), abspath(), etc)? See https://github.com/python/cpython/issues/119671

barneygale avatar Feb 25 '25 19:02 barneygale

Hi! I’m Hridya, a first-year BTech student learning Python. I’d love to work on this issue as part of my GSoC preparation. Can I take it?

hridyasadanand avatar Mar 29 '25 03:03 hridyasadanand

Hey @picnixz if this is still open / stale can I get assigned for this? Would love to leave my footprint on os lib.

rozeappletree avatar Jul 09 '25 08:07 rozeappletree

There's an open PR but no decision has been made yet. I would advise looking somewhere else to start contributing.

A

AA-Turner avatar Jul 09 '25 13:07 AA-Turner

There's an open PR but no decision has been made yet. I would advise looking somewhere else to start contributing.

A

AA-Turner avatar Jul 09 '25 13:07 AA-Turner