python / python/python-docs-es

`pospell` fails with code entries

Open
#3,324 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
371
Forks
413
PR merge metrics
No merged PRs in 30d

Description

For 3.13, there was a change in the documentation that now snippets were marked as translatable.
This means that there is a large number of "new entries" that are snippets from the documentation page.

Even though I believe this is a great thing, the tooling around might need to be adapted.
Recently I discovered that in some cases, pospell fails to parse and handle such entries.

For example:

#: ../Doc/library/typing.rst:3167
msgid ""
"@type_check_only\n"
"class Response:  # private or not available at runtime\n"
"    code: int\n"
"    def get_header(self, name: str) -> str: ...\n"
"\n"
"def fetch_response() -> Response: ..."
msgstr ""
"@type_check_only\n"
"class Response:  # privada o no disponible en runtime\n"
"    code: int\n"
"    def get_header(self, name: str) -> str: ...\n"
"\n"
"def fetch_response() -> Response: ..."

Produces a

<rst-doc>:3: (ERROR/3) Unexpected indentation. while parsing: @type_check_only
class Response:  # privada o no disponible en runtime
    code: int
    def get_header(self, name: str) -> str: ...

def fetch_response() -> Response: ...

Marking those entries as fuzzy or adding three back-ticks "```" doesn't work, so I'm trying to brainstorm a bit how we could solve this.
A couple of ideas would be to:

  1. Just try to fix at the docutils level (which is the source of the parsing error)
  2. Introduce a new identifier like python-format in order to take the content for granted and avoid parsing it.

Ideas?

CC: @JulienPalard

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the multiline PO entry referenced from Doc/library/typing.rst, then inspect how pospell passes code entries to docutils. Determine whether the required change belongs in pospell or at the docutils level; done should mean these entries are handled without the reported parsing error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.