1. The document discusses various techniques for testing functions in Go that depend on the time.Now() function, including overriding time.Now(), using a fake clock interface, and monkey patching.
2. It provides examples of overriding time.Now() directly, using a fakeclock.FakeClock type from the clock package to inject a test clock, and monkey patching time.Now() using the monkey package.
3. The techniques allow isolating tests by faking the system time so time-dependent code returns predictable outputs for different test cases.
28. ? aptpod, Inc. All Rights Reserved. 2 8
3. Sphinxの柔軟さを活用しながら
カスタマイズ?改善
29. 改善してきたことのうちいくつかをご紹介
? aptpod Inc. All Rights Reserved. 2 9
? A. PDFスタイルのカスタマイズ
? B. HTML化
? C. 検索エンジンMeilisearchの導入(HTML用)
Sphinxには、これ以外にも便利な機能はたくさんありますし、同様のことを実現するた
めのもっと良い方法もあるかもしれません。
ここで紹介する方法がすべてではないということをご了承ください。
30. A. PDF出力のカスタマイズ
? aptpod Inc. All Rights Reserved. 3 0
? 表紙
? ヘッダー、フッター
? 目次のスタイル
? 章?節?項タイトルのスタイル
? 警告?注意などの囲みのスタイル
31. カスタマイズの入り口 設定ファイルconf.py
? aptpod Inc. All Rights Reserved. 3 1
画像
(png他)
PDF
LaTeX
設定
conf.py
テキスト
(reStructuredText)
Sphinxプロジェクト(ディレクトリ)
HTML
32. 設定ファイルconf.py
? aptpod Inc. All Rights Reserved. 3 2
# -- Project information -----------
project = 'テストドキュメント'
copyright = '2023, my name'
author = 'my name'
release = 'v1.0'
# -- General configuration ----------
extensions = []
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
language = 'ja'
# -- Options for HTML output ---------
html_theme = 'alabaster'
html_static_path = ['_static']
...以下略
33. PDF出力のカスタマイズ
? aptpod Inc. All Rights Reserved. 3 3
? Sphinxでパラメーターが用意されているものはそれを変更
? ただし、設定可能なパラメーターは少ない
例:
latex_show_pagerefs = True
設定ファイルconf.pyに以下を追加
34. PDF出力のカスタマイズ
? aptpod Inc. All Rights Reserved. 3 4
? latex_elementsのpreambleにLaTeXのコードを書く
latex_elements = {
'preamble': '<ここに書いたものは、LaTeXプリアンブルとして出力される>'
}
(または、外部ファイルに書いて読み込ませるように設定)
設定ファイルconf.pyに以下を追加
48. 複数プロジェクトを統合
? aptpod Inc. All Rights Reserved. 4 8
? いくつかの冊子だったものを1つのサイトに統合
? そのうえで、複数のPDF分冊として出力するよう設定
Sphinx
Project A
統合したSphinx Project
Sphinx
Project B
Sphinx
Project C
アプリA説明書
PDF
アプリB説明書
PDF
アプリC説明書
PDF HTML
アプリA説明書
PDF
アプリB説明書
PDF
アプリC説明書
PDF
49. 1つのプロジェクトで複数のPDFを出力する
? aptpod Inc. All Rights Reserved. 4 9
latex_documents = [
# (PDF出力対象の各ドキュメントroot, LaTeXファイル名, ..以下略)
('app-a/index', 'app-a.tex', ...),
('app-b/index', 'app-b.tex', ...),
('app-c/index', 'app-c.tex', ...),
]
設定ファイルconf.py
50. タブの表現
? aptpod Inc. All Rights Reserved. 5 0
? sphinx-tabsという拡張
? インストール
? 設定ファイルconf.pyに extensions = ['sphinx_tabs.tabs'] を指定
.. tabs::
.. tab:: Go
プロジェクトルートにて以下の...
.. tab:: Python
.....
.. tab:: Rust
.....
51. コードブロックのコピーボタン
? aptpod Inc. All Rights Reserved. 5 1
? sphinx-copybuttonという拡張
? インストール
? 設定ファイルconf.pyに extensions = ['sphinx_copybutton'] を指定
52. Googleアナリティクス導入
? aptpod Inc. All Rights Reserved. 5 2
Read the Docs Sphinx Themeや、PyData Sphinx Themeでは、設
定ファイルconf.pyにGoogleアナリティクスIDを設定するだけ
html_theme_options = {
'analytics_id': 'G-XXXXXXXXXX'
}
設定ファイルconf.py ( Read the Docs Sphinx Themeの場合)
53. C. 検索エンジンMeilisearchの導入(HTML用)
? aptpod Inc. All Rights Reserved. 5 3
? Meilisearchという全文検索エンジンを導入
参考: Vさんが公開されている記事
https://voluntas.medium.com/オンラインドキュメントと日本語全文検索-30cc38d7b1c3
54. Meilisearchを使うための準備1
? aptpod Inc. All Rights Reserved. 5 4
? 専用ツールでドキュメントをスクレイピングして、できたインデックス
をMeilisearchサーバーに送る
Meilisearchサーバー
docs-scraper
(Meilisearchの
専用スクレイピングツール)
インデックスを
アップロード
ページを取得
55. Meilisearchを使うための準備2
? aptpod Inc. All Rights Reserved. 5 5
? SphinxのHTMLテーマをカスタマイズする
? 検索ボックスを、Meilisearchが提供する docs-searchbar.js
(https://github.com/meilisearch/docs-searchbar.js) に差し替える
? 前ページの手順で作成したインデックスを使用するように指定する
Meilisearchサーバー
Sphinxテーマのなかで、
検索ボックスの部分を
差し替え
検索クエリ
結果
56. 柔軟であるということ
? aptpod Inc. All Rights Reserved. 5 6
? カスタマイズが可能な個所がいくつもある
? 設定ファイルconf.pyでの設定
? 機能拡張の利用
? (HTML) テーマの一部を置き換え
? (HTML) CSS追加読み込み
? (PDF) LaTeXコードの追加(コマンド再定義など)
? などなど...
57. カスタマイズ情報の入り口
? aptpod Inc. All Rights Reserved. 5 7
? 設定
https://www.sphinx-doc.org/ja/master/usage/configuration.html
58. 今後の課題として考えていること
? aptpod Inc. All Rights Reserved. 5 8
? ウェブサイトとして利用しやすい形に構造を整理
? HTMLページのスタイルの改善
? TMS(翻訳マネージメントシステム)の利用