Skip to content

go/doc: ToHTML should support headings in non-roman scripts #7349

Closed
@gopherbot

Description

by hiroki.ingk:

I would like to get support for GoDoc to generate headings for non-alphabetic languages.

I tried generating GoDoc with comments in Japanese language. However, as go/doc.ToHTML()
treats only a line beginning with a capital alphabetic letter without punctuation as a
heading, any Japanese lines are treated as normal paragraphs. So I would like to make
comments in Japanese and other non-alphabetic languages available to be judged as
headings properly.

http://golang.org/src/pkg/go/doc/comment.go?s=6479:6541#L248

It is possible to think about some ways to solve it as follows:

  1. Include a language information tag somewhere in the comment and let ToHTML() judge for the corresponding language.

    For example, a GoDoc comment begins like:

    /*
        {"language", "ja"}
        fmtパッケージは、C言語のprintfおよびscanfに似た機能を持つ、
        フォーマットのためのI/Oを実装します。フォーマットに用いる「動詞」は
        C言語から派生されていますが、より簡素なものになっています。

    While we need to decide a rule for the language tag, heading judgment process will be simple.

  2. Make ToHTML() judge for all supported languages universally

    For example, if we support Japanese, Chinese, and Korean as non-alphabetical languages, all the checks for 3 languages and the current alphabetic script will run.
 
    While we do not have to make any changes for the current comment format, the performance will be deteriorated as the number of supported languages increases.

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions