jpugdoc

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MTTransStart = "«"
	MTTransEnd   = "»"
	MTL          = len(MTTransStart)
)

Variables

View Source
var (
	ErrVersionTag = fmt.Errorf("version tag error")
	ErrMemberName = fmt.Errorf("member name error")
	ErrNoMatch    = fmt.Errorf("no match")
)
View Source
var (
	COMMENTSTART = regexp.MustCompile(`<!--`)
	COMMENTEND   = regexp.MustCompile(`-->`)
)
View Source
var (
	MultiSpace = regexp.MustCompile(`\s+`)
	MultiNL    = regexp.MustCompile(`\n+`)
)

複数のスペースと一致

View Source
var (
	KUTEN  = regexp.MustCompile(`。`)
	KUTEN2 = regexp.MustCompile(`。)? ?`)
)
View Source
var BLANKBRACKET = regexp.MustCompile(`(?s)(<\!--\n(.*?)-->\n(.*?))(《》)\n`)
View Source
var BLANKBRACKET2 = regexp.MustCompile(`(?s)(.*?)-->\n(.*?)(《》)\n`)
View Source
var BLANKLINE = regexp.MustCompile(`^\s*\n`)
View Source
var BLANKSLINE = regexp.MustCompile(`(?m)^\n+`)
View Source
var CHECKPARA = regexp.MustCompile(`\s*(<!--\n?\s+)?(?s)(<para>\n*)(.*?)(\s*</para>)(\n*\s*-->)?`)

<para> </para> に一致させる(チェック用)

View Source
var CLOSEPARA = regexp.MustCompile(`</para>`)
View Source
var Config jpugDocConfig
View Source
var DicDir = filepath.Join(".", ".jpug-doc-tool/")
View Source
var ENAUTHOR = regexp.MustCompile(`\([a-zA-ZÀ-ÿ, \.\-]+\)$`)
View Source
var ENDADDCOMMENT = regexp.MustCompile(`\+-->$`)

コメント終わりの追加に一致

View Source
var ENDADDCOMMENTWITHC = regexp.MustCompile(`\+--><\!\[CDATA\[`)

コメントが終わりCDATAの始まりに一致

View Source
var ENDCOMMENT = regexp.MustCompile(`-->$`)

最後がコメント終わりに一致

View Source
var ENDINDEXTERM = regexp.MustCompile(`</indexterm`)

indexterm終わりに一致

View Source
var ENNUM = regexp.MustCompile(`[0-9,]+`)

数値

View Source
var ENTRYNEWLINE = regexp.MustCompile(`(?s)<entry>(.*?)</entry>`)
View Source
var ENTRYSTRIP = regexp.MustCompile(`</?entry>`)

<entry> </entry> と一致

View Source
var ENWORD = regexp.MustCompile(`[/a-zA-Z_]+`)

英単語 + /

View Source
var EXCOMMENT = regexp.MustCompile(`(?s)<!--(.*?)-->(.*?)(</row>|<!--|<note>|<informaltable>|<footnote>|<screen>|<synopsis>|<variablelist>|<programlisting>|<itemizedlist>|<simplelist>|<itemizedlist|<orderedlist|</para>)`)

コメント(英語原文)と続く文書(日本語翻訳)を取得 100%一致する訳ではない

View Source
var HANKAKUKAKKO = regexp.MustCompile(`\((.*?)\)`)
View Source
var KATAKANA = regexp.MustCompile(`[ァ-ヺー・]+`)

カタカナ

View Source
var MTMARKREG = regexp.MustCompile(`«(.*?)»`)
View Source
var NIHONGO = regexp.MustCompile(`[\p{Han}\p{Katakana}\p{Hiragana}]`)

日本語

View Source
var NONSTRIPPERIOD = regexp.MustCompile(`\.\.\.|etc\.|Eg\.`)

文の終わりではないピリオドを除外

View Source
var RECHECKTITLE = regexp.MustCompile(`(?s)(<!--\n\s*<title>\n*)(.*?)(\s*</title>\n*\s*-->\n\s*<title>(.*?)</title>)`)

<title> </title> をコメントを含めて一致させる

View Source
var RECOMMENT = regexp.MustCompile(`(?s)<!--(.*?)-->`)

XMLのコメントに一致

View Source
var RECOMMENTEND = regexp.MustCompile(`-->`)

XMLのコメント閉じタグに一致

View Source
var RECOMMENTSTART = regexp.MustCompile(`<!--`)

XMLのコメント開始タグに一致

View Source
var REJASTRING = regexp.MustCompile(`[ぁ-ん]+|[ァ-ヴー]+|[一-龠]/`)

var RELIRET = regexp.MustCompile(`(?s)(<para>\n*)\s*<literal>.*</literal>\n`)

View Source
var RELEASENUM = regexp.MustCompile(`[0-9\.]+`)
View Source
var RELIRET = regexp.MustCompile(`(?s)(<para>\n*)\s*<literal>.*</literal>\n*\s*<returnvalue>.*</returnvalue>(\s*</para>)`)

<para><literal></literal><returnvalue></returnvalue></para>に一致させる

View Source
var RELIRETPROG = regexp.MustCompile(`(?s)(<para>\n*)\s*<literal>.*</literal>\n*\s*<returnvalue>.*</returnvalue>\n*\s*<programlisting>.*</programlisting>(\s*</para>)`)

<para><literal></literal><returnvalue></returnvalue><programlisting></programlisting></para>に一致させる

View Source
var RELITERAL = regexp.MustCompile(`(?s)(<para>\n*)\s*<literal>.*</literal>\n*(\s*</para>)`)

<para><literal></literal></para>に一致させる

View Source
var REPARA = regexp.MustCompile(`(?s)(<para>\n*)(.*?)(\s*</para>)`)

<para> </para> に一致させる

View Source
var REPARA2 = regexp.MustCompile(`(?s)<para>\n(.*?)</para>`)
View Source
var REPARASCREEN = regexp.MustCompile(`(?s)(<para>\n*)(.*?)(\s*(</para>|<screen>|<programlisting>))`)

<para> <screen>|<programlisting> に一致させる

View Source
var REPHIGHHUN = regexp.MustCompile(`&#0?45;`)
View Source
var REROWS = regexp.MustCompile(`(?s)(<row>\n*)(.*?)(\s+</row>)`)

<row> </row> に一致させる

View Source
var RETAG = regexp.MustCompile(`<[^>]+>`)

タグと一致させる

View Source
var RETAGBLOCK = regexp.MustCompile(`^\s*<([^>]+)>\n`)

単独タグ(\s+<programlisting>\nなど)に一致させる

View Source
var RETITLE = regexp.MustCompile(`(?s)(<title>\n*)(.*?)(\s*</title>)`)

<title> </title> に一致させる

View Source
var REVHIGHHUN = regexp.MustCompile(`--`)
View Source
var REVHIGHHUN2 = regexp.MustCompile(`---`)
View Source
var SPLITCATALOG = regexp.MustCompile(`(?s)␝(.*?)␟(.*?)␟(.*?)␞(.*?)␞(.*?)␞`)

カタログから英語と日本語を取得

View Source
var SPLITCOMMENT = regexp.MustCompile(`split-.*-[start|end]`)

split-*コメントに一致

View Source
var STARTADDCOMMENT = regexp.MustCompile(`\+<!--$`)

コメント始まりの追加に一致

View Source
var STARTADDCOMMENTWITHC = regexp.MustCompile(`\+(.*)?\]\]><!--`)

CDATAが終わりコメントの始まりに一致

View Source
var STARTCOMMENT = regexp.MustCompile(`^<!--`)

最初がコメント始まりに一致

View Source
var STARTINDEXTERM = regexp.MustCompile(`<indexterm`)

indexterm始まりに一致

View Source
var STARTSPACE = regexp.MustCompile(`^\s+`)

最初の連続スペースを一つのスペースに変換

View Source
var STRIPM = regexp.MustCompile(`《.*》`)

《》で囲まれた文字列(作業中)に一致させる

View Source
var STRIPNONJA = regexp.MustCompile(`[\s\,\(\)\.a-zA-Z0-9\-\/\<\>\n*]+$`)

最後尾の日本語以外を除外

View Source
var STRIPNUM = regexp.MustCompile(`,`)

カンマを除外

View Source
var STRIPNUMJ = regexp.MustCompile(`, |,|、`)

カンマを除外

View Source
var STRIPPMT = regexp.MustCompile(`(?s)《機械翻訳》.*`)
View Source
var STRIPPROGRAMLISTING = regexp.MustCompile(`<(programlisting|screen)>.*</(programlisting|screen)>`)

<programlisting>.*</programlisting> を除外

View Source
var STRIPXREFLABEL = regexp.MustCompile(`xreflabel=\".*\"`)

xreflabelは除外

View Source
var TITLE = regexp.MustCompile(`(?U)\n( *<title>[a-zA-Z0-9 \.\-:]+</title>)\n([^\-])`)
View Source
var TITLE2 = regexp.MustCompile(`(?U)<!--\s*(<title>.*</title>)\s*-->\s*(<title>.*</title>)`)
View Source
var Verbose bool
View Source
var Version = "dev"
View Source
var XMLTAG = regexp.MustCompile(`<[^>\!]*?>|<[^<>]+/>`)

XMLタグ

View Source
var YAKUCHU = regexp.MustCompile(`[\(|\[|(]訳注[^\[|\)|)]]*[\]|\)|)]`)

訳注を除外

Functions

func Check

func Check(fileNames []string, cf CheckFlag) error

default check

func CheckWord

func CheckWord(en string, ja string, vTag string, fileNames []string) error

CheckWord checks if the given English word (en) is paired with the corresponding Japanese word (ja) in the specified files. If both en and ja are provided, it identifies pairs where the English word exists but the Japanese word does not. If only en is provided, it checks for the presence of the English word. If only ja is provided, it checks for the presence of the Japanese word.

Parameters:

  • en: The English word to search for.
  • ja: The Japanese word to search for.
  • vTag: The version tag to use for retrieving file differences. If empty, it will be determined automatically.
  • fileNames: A list of file names to search within.

Returns:

  • An error if there is an issue retrieving the version tag or file differences, or nil if the operation completes successfully.

Example:

err := CheckWord("example", "例", "v1.0", []string{"file1.txt", "file2.txt"})
if err != nil {
    log.Fatal(err)
}

func Extract

func Extract(vTag string, fileNames []string) error

ファイル名の配列を受け取り、それぞれのファイル名のdiffから原文と日本語訳の対の配列を抽出し、 それぞれのファイル名に対応するカタログファイル(filename.sgml.t)を作成する

func ExtractCommon added in v0.7.0

func ExtractCommon(vTag string, fileNames []string) error

func IgnoreFileNames

func IgnoreFileNames(fileNames []string) []string

func InitJpug

func InitJpug()

func List

func List(opt ListOoptions, fileNames []string)

英日辞書の内容を表示する fileNames: ファイル名のリスト

func ListCommon added in v0.7.0

func ListCommon(opt ListOoptions)

func MT

func MT(w io.Writer, origin string) error

MT はoriginを機械翻訳し出力します。

func MTReplace added in v0.3.0

func MTReplace(fileNames []string, limit int, prompt bool) error

func ParaAll

func ParaAll(src []byte) [][]byte

文書から <para> </para>を取得してsliceで返す

func ReadAllFile

func ReadAllFile(fileName string) ([]byte, error)

func Replace

func Replace(fileNames []string, vTag string, update bool, similar int, mt int, wip bool, prompt bool) error

Replace は指定されたファイル名のファイルを置き換える

func RowsAll

func RowsAll(src []byte) [][]byte

文書から <rows> </rows>を取得してsliceで返す

func StripEntry

func StripEntry(src []byte) []byte

entryタグを取り除くために使用

func TSVList

func TSVList(strip bool, fileNames []string)

英日辞書の内容をTSV形式で表示する

Types

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog は原文と日本語訳の対を保持する構造体

func Extraction

func Extraction(diffSrc []byte) []Catalog

diff を原文と日本語訳の対(Catalog)の配列に変換する <para> +<!-- english +--> +japanese </para>

func (Catalog) String added in v0.3.0

func (c Catalog) String() string

type Catalogs added in v0.7.0

type Catalogs []Catalog

func (Catalogs) String added in v0.7.0

func (cs Catalogs) String() string

type CheckFlag

type CheckFlag struct {
	VTag     string
	Ignore   bool
	WIP      bool
	Para     bool
	Word     bool
	Tag      bool
	Num      bool
	Author   bool
	Strict   bool
	Sentence bool
	// contains filtered or unexported fields
}

CheckFlag represents the item to check.

type IgnoreList

type IgnoreList map[string]bool

type ListOoptions added in v0.7.0

type ListOoptions struct {
	WriteFile bool // wf: ファイル名を表示する
	IsPre     bool // pre: preタグを表示する
	ENOnly    bool // enOnly: 英文のみ表示する
	JAOnly    bool // jaOnly: 日本語のみ表示する
	Strip     bool // strip: 空白を削除する
	Sentence  bool // sentence: 文で改行する
}

type MTType added in v0.3.0

type MTType struct {
	APIAutoTranslateType string
	// contains filtered or unexported fields
}

func (*MTType) Replace added in v0.3.0

func (mt *MTType) Replace(src string, prompt bool) (string, error)

func (*MTType) ReplaceText added in v0.3.0

func (mt *MTType) ReplaceText(src string) (string, error)

type Rep

type Rep struct {
	// contains filtered or unexported fields
}

Rep は置き換えを行う構造体

func NewRep added in v0.7.0

func NewRep(vTag string, update bool, similar int, mt int, prompt bool) (*Rep, error)

NewRep はRep構造体を初期化する関数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址