これは、このセクションの複数ページの印刷可能なビューです。 印刷するには、ここをクリックしてください.

このページの通常のビューに戻る.

Seleniumのサイトとドキュメントに貢献する

Seleniumのドキュメントとコード例を改善するための情報

Seleniumは大きなソフトウェアプロジェクトであり、そのサイトとドキュメントは、物事の仕組みを理解し、その可能性を活用する効果的な方法を学ぶための鍵となります。

このプロジェクトには、Seleniumのサイトとドキュメントの両方が含まれています。これは、Seleniumを効果的に使用する方法、Seleniumに参加する方法、およびSeleniumに貢献する方法に関する最新情報を提供するための継続的な取り組みです(特定のリリースを対象としていません)。

サイトおよびドキュメントへの貢献は、以下のセクションで説明されているプロセスに従います。


Seleniumプロジェクトは、皆様からのコントリビューションを歓迎します。 お手伝いをいただくには、いくつかの方法があります:

イシュー報告

新しい問題を報告したり、既存の問題についてコメントしたりするときは、議論がSeleniumソフトウェア、そのサイトおよび/またはドキュメントに関する具体的な技術問題に関連していることを確認してください。

Seleniumのすべてのコンポーネントは、時間の経過とともに非常に速く変化するため、ドキュメントが古くなる可能性があります。 このようなケースを見つけた場合には、遠慮なくイシューを作成してください。 また、ドキュメントを最新の状態に更新する方法をご存知でしたら、関連する変更を含むプルリクエストを送ってしてください。

見つかったものが問題であるかどうかわからない場合、https://selenium.dev/supportに記載されているコミュニケーション手段にて質問してください。

何を手伝うか

例の作成

追加が必要な例には、次のマークが付いています:

Add Example

すべてのコード例をCIで実行できるようにし、サイト上のすべてのコードをコピー&ペーストして実行できることを確認したいと考えています。そのため、コードをexamplesディレクトリの適切な場所に配置します。 ドキュメントの各ページは各言語のテストファイルに関連しており、命名規則に従う必要があります。 例えば、このページ(https://www.selenium.dev/documentation/webdriver/browsers/chrome/)の例は以下のファイルに追加されています:

  • "/examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java"
  • "/examples/python/tests/browsers/test_chrome.py"
  • "/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs"
  • "/examples/ruby/spec/browsers/chrome_spec.rb"
  • "/examples/javascript/test/browser/chromeSpecificCaps.spec.js"

各例はそれぞれ独自のテストが必要です。理想的には、各テストにはコードが意図したとおりに動作することを確認するアサーションが含まれています。 コードを適切なファイル内の独自のテストにコピーしたら、Markdownファイルで参照する必要があります。

例えば、Rubyのtabは次のようになります:

    {{< tab header="Ruby" >}}
    {{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L8-L9" >}}
    {{< /tab >}}

末尾の行番号は、実際に表示される項目を表すコードの行のみを表します。 ユーザーがより多くのコンテキストを必要とする場合、GitHubページへのリンクをクリックすると完全なコンテキストが表示されます。

ページにテストを追加する場合は、Markdownファイル内の他のすべての行番号が正しいことを確認してください。 ページの先頭にテストを追加すると、そのファイルの行番号を持つドキュメント内のすべての参照が更新されます。

コード例では、シナリオを示すために関連するWebサイトやWebページが必要になる場合があります。 例が安定して動作するように、https://www.selenium.dev/selenium/web/ で利用できるテスト用Webページを使用することを推奨します。

最後に、CIでテストがパスすることを確認してください。

例の移動

移動が必要な例には、次のマークが付いています:

Move Code

例の作成セクションのすべてが適用されますが、1つ追加があります。

tabにはtext=trueを含めてください。デフォルトではtabはコード用にフォーマットされるため、Markdownや他のショートコードステートメント(gh-codeblockなど)を使用するには、text=trueを宣言する必要があります。 ほとんどの例では、tabpaneがtext=trueを宣言しますが、tabの一部にコード例が含まれている場合、tabpaneはそれを指定できず、自動コードフォーマットが不要なtabでは指定する必要があります。

貢献

Seleniumプロジェクトは新しいコントリビュータを歓迎します。目立った価値ある貢献を継続的に行った個人は コミッター として認められ、プロジェクトへのコミットアクセス権が与えられます。

本ガイドでは、貢献のプロセスについて説明します。

ステップ 1: フォーク

GitHub上のプロジェクトをフォークし、コピーをローカルにチェックアウトしてください。

% git clone git@github.com:seleniumhq/seleniumhq.github.io.git
% cd seleniumhq.github.io

依存関係: Hugo

HugoとDocsyテーマを使用してサイトの構築とレンダリングをしています。このサイトの作業をするには、Hugoバイナリの“拡張”Sass/SCSSバージョンが必要です。Hugo 0.167.0の使用を推奨します。

Docsyのインストール手順に従ってください。

依存関係: Go

DocsyテーマはHugo Moduleとして取り込まれているため、 hugo serverを実行する際にHugoがこれを解決するにはGoが必要です。 go.modに記載された最小バージョンを満たす任意のバージョンをインストールしてください。

依存関係: Node.js(省略可、本番用CSSパイプライン向け)

hugo serverでサイトをプレビューするだけであれば、Node.jsは不要です。開発モードでは Docsyが PostCSS の処理をスキップします。ローカルのビルドを、build-site.sh内の hugo --minifyが実行する本番用CSSパイプライン(autoprefixer/PostCSS)に合わせたい場合にのみ、 Node.js(現行の任意のリリース)が必要です。その場合は、先に website_and_docsでnpm installを実行してください。

注: 今後のHugo/Docsyのアップグレードで状況が変わる可能性があります。テーマのアセット (例: BootstrapやFont Awesome)がHugo Modulesからnpmパッケージへ移行された場合、 npm install(つまりNode.js)が本番用パイプラインだけでなく、すべてのビルドで 必要になることがあります。

ステップ 2: ブランチの作成

フィーチャーブランチを作成し、ハックを開始します。:

% git checkout -b my-feature-branch

我々はHEADベースの開発を行っています。つまり、全ての変更はtrunkブランチ上に直接適用されます。

ステップ 3: 変更を加える

リポジトリにはサイトとドキュメントが含まれています。 変更を加える前に、submoduleを初期化し、必要な依存関係をインストールしてください(以下のコマンドを参照)。サイトに変更を加えるには、website_and_docs ディレクトリで作業してください。変更のライブプレビューを確認するには、サイトのルートディレクトリで hugo serverを実行してください。

% git submodule update --init --recursive
% cd website_and_docs
% hugo server

寄稿に関する規約の詳細については、 スタイルガイド をご覧ください。

ステップ 4: コミット

まず、gitがあなたの名前とメールアドレスを知っていることを確認してください:

% git config --global user.name 'Santa Claus'
% git config --global user.email 'santa@example.com'

**適切なコミットメッセージを書くことは重要です。**コミットメッセージには、変更された内容、理由、修正されたイシューへの参照(ある場合)を記述する必要があります。作成するときは、次のガイドラインに従ってください。:

  1. 最初の行は約50文字以下で、変更の簡単な説明を含める必要があります。
  2. 2行目は空白のままにします。
  3. 他のすべての行を72列で折り返します。
  4. Fixes #Nを含めてください。ここでは N がこのコミットで修正したイシュー番号です(存在する場合)。

適切なコミットメッセージは次のようになります:

explain commit normatively in one line

Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc.

The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
72 characters or so. That way `git log` will show things
nicely even when it is indented.

Fixes #141

最初の行はgit shortlogやgit log --onelineを実行した際に他人が最初に目にするため、意味のあるものでなければなりません。

ステップ 5: リベース

あなたの作業を同期するため、(git mergeではなく)git rebaseを時々実行してください。

% git fetch origin
% git rebase origin/trunk

ステップ 6: テスト

あなたの変更が何も問題を起こしていないことを確認するため、常に忘れずにローカルサーバーの実行を行ってください。

ステップ 7: プッシュ

% git push origin my-feature-branch

https://github.com/yourusername/seleniumhq.github.io.git を開き、 Pull Request を押し、 フォームを入力してください。 CLAに署名したことを示してください。 CLAに署名するには、 cla-assistant.io/SeleniumHQ/seleniumhq.github.io にアクセスし、ページ上の"Sign in with GitHub to agree"ボタンをクリックしてください。

プルリクエストは通常数日以内にレビューされます。対応すべきコメントがある場合は、新しく(できれば fixupsで)コミットし、同じブランチにプッシュしてください。

ステップ 8: 統合

コードレビューが完了すると、コミッターがPRを取得し、リポジトリのtrunkブランチに統合します。 マスターブランチで履歴を線形に保持するのが好きなので、通常はブランチの履歴をスカッシュしてリベースします。

コミュニケーション

プロジェクトのコントリビューターおよびコミュニティ全体と交流する方法については、全て https://selenium.dev/support で詳細が記載されています。

1 - Contributing to the Selenium site

How to update the Selenium site pages outside of the documentation

The Selenium site is built with Hugo and the Docsy theme. The site root is the website_and_docs directory. Follow the contribution mechanics to set up your environment and preview your changes with hugo server.

Where things live

WhatWhere
Home pagecontent/_index.<language>.html
Top level pages (downloads, support, projects, sponsors, etc.)content/<page>/_index.html
Blog postscontent/blog/<year>/<post>.md
Page templates (e.g., the downloads page)layouts/<section>/list.html
Shortcodeslayouts/shortcodes/
Partials (navbar, footer, announcement banner, etc.)layouts/partials/
Images and other static filesstatic/ (e.g., static/images/)
Stylesassets/scss/
Structured data (e.g., sponsors)data/
Site configuration and menushugo.toml

Some pages have most of their content in the template instead of the Markdown file. For example, the content of the Downloads page lives in layouts/downloads/list.html.

Blog posts

Add a new Markdown file under content/blog/<year>/. Copy the front matter of a recent post and update the title, linkTitle, date, tags, categories, author, and description. To use a custom image when the post is shared on social media, add it under static/images/blog/<year>/ and reference it in the images front matter key.

Translations

The home page and the documentation are translated. Most of the other site pages, including the blog, are only available in English. When you change text on a translated page, see Translations in the style guide.

Checking your changes

Site changes are not covered by tests, so preview every page you changed with hugo server. Every pull request gets a Netlify deploy preview; check it before asking for a review.

2 - Contributing to the Selenium documentation

How the Selenium documentation is organized and how to change it

The documentation lives in website_and_docs/content/documentation. Follow the contribution mechanics to set up your environment and preview your changes with hugo server.

Structure

Each directory is a section of the documentation, and its _index.<language>.md file is the section landing page. Each page has one file per language:

  • <page>.en.md
  • <page>.ja.md
  • <page>.pt-br.md
  • <page>.zh-cn.md

When you add a page, add a file for each language. If you are not translating the content, copy the English text into the other language files.

Each page starts with front matter like this:

---
title: "Sentence capitalization title that describes the page"
linkTitle: "Short Title"
weight: 4
description: >
  One sentence summary of the page.
---

weight defines the order of the page in the navigation. See Capitalization of titles for the title and linkTitle conventions.

Writing

  • Keep the prose language independent. Anything specific to a language binding goes inside code tabs.
  • Follow the style guide for line length, alerts, and code tabs.
  • Mark missing content with the alerts described in the style guide, so others know where help is needed.
  • Link to other documentation pages with the ref shortcode, e.g., [Waits]({{< ref "waits.md" >}}), so broken links fail the build.

Code in the documentation

Code shown in the documentation must come from runnable examples. See Code examples for how to create them and render them on a page.

Translations

See Translations in the style guide.

3 - Contributing code examples

How to create runnable code examples and render them in the documentation

We want to be able to run all of our code examples in the CI to ensure that people can copy, paste and execute everything on the site. So the code lives in the examples directory, and the documentation renders it from there.

Creating examples

Examples that need to be added are marked with:

Add Example

Each page in the documentation correlates to a test file in each of the languages, and should follow naming conventions. For instance examples for this page https://www.selenium.dev/documentation/webdriver/browsers/chrome/ get added in these files:

  • "/examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java"
  • "/examples/python/tests/browsers/test_chrome.py"
  • "/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs"
  • "/examples/ruby/spec/browsers/chrome_spec.rb"
  • "/examples/javascript/test/browser/chromeSpecificCaps.spec.js"
  • "/examples/kotlin/src/test/kotlin/dev/selenium/browsers/ChromeTest.kt"

Follow these guidelines when writing an example:

  • Each example gets its own test. This keeps the example focused and lets the documentation point to exactly the lines that matter.
  • Use the Selenium test pages. Examples need a web page to work against. Use the pages available at https://www.selenium.dev/selenium/web/ instead of third party sites, which can change or go offline and break the examples.
  • Assert the outcome. Each test should have an assertion that verifies the code works as intended, so that a broken example fails the CI.
  • Keep the shown code free of test noise. Write the test so that the lines shown in the documentation are only the Selenium code the reader needs. Assertions and test setup are not shown, unless the assertion is the clearest way to show the result of the command (e.g., the value returned by a getter).
  • Run the tests. Run the tests for each language you changed locally, and make sure they pass in the CI. Each language directory in the examples directory has a README with the instructions to run its tests.

Moving examples

Examples that need to be moved are marked with:

Move Code

These are code examples that are written directly in the Markdown file. Everything from Creating examples applies: move the code into a test, then render it with gh-codeblock as described below.

Rendering examples

Once the code is in its own test, it needs to be referenced in the Markdown file with the gh-codeblock shortcode. For example, the tab in Ruby would look like this:

    {{< tab header="Ruby" >}}
    {{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L8-L9" >}}
    {{< /tab >}}

See Reference GitHub Examples in the style guide for the complete tabpane syntax. Keep in mind the following:

  • Show only the relevant lines. The line numbers at the end of the path (#L8-L9) select the lines that are displayed. Use a single line (#L8) or a range of lines (#L8-L9). Readers can click “View Complete Code” or “View on GitHub” to see the full test.
  • One range per code block. A gh-codeblock displays one continuous range of lines. If the lines you want to show are not next to each other, reorganize the test so they are, or use one gh-codeblock for each range.
  • Use text=true. By default, the tabs get formatted for code, so to use markdown or other shortcode statements (like gh-codeblock) it needs to be declared as text. For most examples, the tabpane declares the text=true, but if some of the tabs have code examples, the tabpane cannot specify it, and it must be specified in the tabs that do not need automatic code formatting.
  • Do not indent the gh-codeblock line. An indented line is rendered as a Markdown code block instead of running the shortcode.
  • Keep line numbers up to date. When you add, remove or move lines in an example file, every gh-codeblock that points to that file below the change needs new line numbers. Search website_and_docs/content for the file path, and check all languages of the page.
  • Add the example to all translations. Update the gh-codeblock references in the .ja.md, .pt-br.md and .zh-cn.md files of the page too.