Outdated version of the documentation. Find the latest one here.

一歩ずつの貢献

ノート

手順を説明するためにQGIS文書を使用していますが、以下で示すコマンドおよび手順はすべてQGISウェブサイトにも適用されます。

Now that you know the rules to follow to write a clean doc for QGIS, let’s dive in the process of production of this documentation and how quickly and safely share your changes with the community.

Assuming you already have a GitHub account, you first need to clone the source files of the documentation in order to have your own copy you can work on: go to the QGIS-Documentation repository page (for convenience, this repository is called below qgis/QGIS-Documentation) and click on the Fork button in the upper right corner.

Few seconds later, in your GitHub account you find a QGIS-Documentation repository (https://github.com/<YourName>/QGIS-Documentation). This repo is a safe copy in which you have full write access and can push all your contributions without a risk to affect the official documentation. At the beginning, this repository contains the same branches as qgis/QGIS-Documentation and is defaulted to master branch. Branches are parallel lines of development containing different snapshots of the doc that may merge or diverge. Preferably create a branch for each issue you want to tackle and you can create as many branches as you want.

ちなみに

Do your changes in an ad’hoc branch, never in master

By convention, avoid making changes in your master branch except merging the modifications from the master branch of qgis/QGIS-Documentation (called qgis:master). And use it as model to create new branches for a clean history and snapshot.

There are different ways to contribute to QGIS documentation. Though we expose them below separately, they are not mutually exclusive, meaning that you can, at any moment, switch from one process to another without any harm because they both follow the scheme below:

  1. Do your modifications in an ad’hoc branch of your repository
  2. Publish your changes and ask for merging in the main doc through a pull request (PR)
  3. Others review, discuss and integrate your work in the main branch when everything seems ok.

Using GitHub web interface

From your cloned repository, you can now propose changes to the main documentation. Indeed, GitHub web interface offers you ways to easily:

  • edit files, preview and commit your changes
  • make a pull request to have your changes inserted in the main repo
  • create, update or delete branches

GitHubの こんにちは世界 プロジェクトを読んで、以下で使用されるいくつかの基本的な語彙や行動を学んでください。

Make changes in your repo

Documentation can be improved by addressing issues reported at https://github.com/qgis/QGIS-Documentation/issues or issues you may have encountered while browsing the doc. They can be of different types: typo error, missing feature, wrong or out of date description...

Alternative 1: Picking an issue in the list

  1. Select an issue you want to fix. To avoid many persons tackling the same issue, you can inform contributors about your choice by adding a comment to the issue report and get it assigned to you.
  2. From your repository, create (and switch to) a branch with a name that helps you remind what it’s about
  3. Browse the source files to the file that has to be changed
  4. Toggle the file into Edit mode using the pencil icon and do your modifications following guidelines
  5. Validate your changes by filling the Commit Changes frame and commit directly to your branch.
  6. Redo the previous steps for any other file that needs to be updated to fix the issue.

Alternative 2: Using the Fix Me shortcut

The QGIS project provides an easy way to reach source file from online documentation. Indeed, instead of browsing the source files in GitHub to find the one that suits the issue, or if you find an issue while reading the manuals, you simply have to click the “Fix Me” link at the bottom of the page to open its source file in Edit mode.

  1. This will open the file in the qgis:master branch with a message at the top of the page telling you that you don’t have write access to this repo and your changes will be applied in a new branch of your repository.

    Note that if you have commit rights to QGIS-Documentation repository, then no message will show and you’ll directly modify qgis:master branch itself unless you save your changes in another branch.

  2. Do your changes following guidelines available at http://docs.qgis.org/testing/en/docs/documentation_guidelines/

  3. When you finish, at the bottom of the page, comment a bit what your changes are about and click on Propose File change. This will generate a new branch (patch-xxx) in your repo.

ちなみに

If your master branch is even with qgis:master, you can safely replace in the link qgis by <YourName>. In this case, once your changes are done, you need to check radioButtonOn Create a new branch for this commit and start a pull request and avoid modifying master.

Share your changes via Pull Request

Now, you have a new branch in QGIS with a file that diverge from qgis:master. To integrate your changes in the official documentation, you need to do a pull request.

  1. Actually, after you commit your changes, GitHub opens a new dialog comparing branches:

    • if you used the Fix Me without changing the url, then the comparison is between your patch-xxx branch and qgis:master (the base fork is qgis/QGIS-Documentation and its branch master).
    • if you used a branch you had named yourself then the comparison is done between that branch and your own master branch (the base is simply master). You therefore need to leave that page and follow the next step.
  2. In any case (including pushing branch to GitHub from command lines) you can create a new pull request at any moment from many pages. Simply go to the main page of the repository (yours or qgis), click on New Pull Request and Compare across forks (if needed). Ensure you select qgis/QGIS-Documentation with master as base branch and that the head fork is your repository <YourName>/QGIS-Documentation with your modified branch along.

    ちなみに

    Though released and being translated, the documentation of QGIS 2.18 is still maintained and existing issues are fixed. If you plan to fix the issues in the current released doc, replace master branch by the appropriate manual_en_... branch in any of the steps exposed earlier.

  3. A green check along the compared branches shows that your changes can automatically be merged in the official doc. Click the Create pull request button. If you get a red cross, it means that the files you are modifying were not up to date with the branch you are targetting (a commit has been pushed to it since you create or last update your branch). You then need to use git command line tools to fix it.

  4. Fill the form if needed and click again Create pull request button.

  5. A new PR is added to https://github.com/qgis/QGIS-Documentation/pulls and everybody can look or comment it.

  6. That will trigger a Travis CI build automatically checking if your contribution doesn’t contain a build error. In case of error, a red cross appears along your commit. Simply click on it or on Details in the summary section at the bottom of the page to have details on the error. You’ll need to fix any reported error or warning before your changes are committed in the repository.

  7. Until your PR is merged with the main repo, you can add modifications to your proposal. Actually any new changes done to your branch is appended to your pull request. Do it if the change has to do with the issue you are fixing, otherwise create a new branch for those changes following steps above.

  8. Once everything looks good to you and others, a committer can merge your branch with the main repo. Your contribution is validated.

  9. If you want, you can now delete the branch you used, to avoid having too many (unused and outdated) branches crowding your repository.

Doing this little steps will make you learn the process easier.

警告

Be vigilant to pull request against qgis:master and not your own master branch, otherwise nobody is aware of your changes and you may mistakenly merge your changes into your master branch, polluting its history.

ちなみに

Automatically close issue report from pull request

To ease issue reports management, mention the number of the issue you are addressing in your pull-request. This can be done using #issue_number. If preceded by terms like fix, close... the concerned issue is closed as soon as the pull request is merged.

Gitのコマンドラインツールを使用する

GitHub web interface helps you update the repo with your contribution in an easier way but it doesn’t offer tools to:

  • group your commits and clean your changes history
  • fix conflicts with the main repo if needed...
  • 変更をテストするための文書を構築する

You then need to install git on your hard drive in order to get access to more advanced and powerful tools and have a local copy of the repository. Some basics you may often need are exposed below. You’ll also find rules to care about even if you opt for the web interface.

以下のコードサンプルでは、 $ で始まる​​行はあなたが入力する必要があるコマンドを示し、 # はコメントです。

ローカルリポジトリ

これで あなたの QGIS-ドキュメントリポジトリのローカルクローンを取得する準備ができました:

$ cd ~/Documents/Development/QGIS/
$ git clone [email protected]:<YourName>/QGIS-Documentation.git

以前のコマンドラインは、単に一例です。 <YourName> をご自分のユーザー名で置き換え、パスとリポジトリURLの両方を適合させる必要があります。

ちなみに

アクセス権拒否(公開鍵)エラー?

アクセス権拒否(公開鍵)エラーが出る場合は、SSHキーに問題がある可能性があります。詳細は GitHubのヘルプ を参照。

確認してください:

$ git remote -v
origin  [email protected]:<YourName>/QGIS-Documentation.git (fetch)
origin  [email protected]:<YourName>/QGIS-Documentation.git (push)
$ git branch
* master
  • origin は、あなたのQGIS-ドキュメントリポジトリのリモートリポジトリの名前です。

  • master はデフォルトのメインブランチです。あなたは貢献するためにそれを使用しないでください! 決して!

ここで作業を開始できますが、長期のプロセスでは、あなたの貢献をプッシュする(githubのプロセスではプルリクエストと呼ばれる)ときには、QGIS文書リポジトリのマスターブランチはあなたのローカル/リモートリポジトリからは違ってきているので、多くの問題が出るでしょう。

別のリモートリポジトリを追加

メインプロジェクトで作業を追跡できるようにするには、ローカルリポジトリに新しいリモートリポジトリを追加します。この新しいリモートリポジトリはQGISプロジェクトからのQGIS-ドキュメントリポジトリです。

$ git remote add upstream [email protected]:qgis/QGIS-Documentation.git
$ git remote -v
origin  [email protected]:<YourName>/QGIS-Documentation.git (fetch)
origin  [email protected]:<YourName>/QGIS-Documentation.git (push)
upstream        [email protected]:qgis/QGIS-Documentation.git (fetch)
upstream        [email protected]:qgis/QGIS-Documentation.git (push)

だから今は、2つのリモートリポジトリ間の選択肢があります。

  • origin あなたの リモートリポジトリにあなたのローカルブランチをプッシュする

  • upstream あなたの貢献を公式のものにマージ(そうする権利がある場合)したり、公式リポジトリのマスターブランチからローカルリポジトリのマスターブランチを更新します。

ノート

upstream はただのラベルで、標準の名前のようなものですが、好きなようにお呼びください。

お使いのベースのブランチを更新

文書をテストするための( master ブランチ)

新しい貢献に作業を始める前には、常にローカルリポジトリ中のローカルのmasterブランチを更新する必要があります。このコマンドラインを実行するだけです:

# switch to master branch (it is easy to forget this step!)
$ git checkout master
# get "information" from the master branch in upstream repository
# (aka qgis/QGIS-Documentation's repository)
$ git fetch upstream master
# merge update from upstream/master to the current local branch
# (which should be master, see step 1)
$ git merge upstream/master
# update **your** remote repository
$ git push origin master

今、ローカルとリモートのリポジトリは、両方ともQGIS組織からのQGIS文書で master ブランチが最新になっています。あなたの貢献での作業を開始できます。

For released doc (manual_en_ branch)

Along the testing documentation, we continue to fix issues in QGIS 2.18 doc, meaning that you can also contribute to it. Following the previous section sample code, you can easily do that by selecting the corresponding branch.

リポジトリのクローンを作成するとき( ローカルリポジトリ 参照)、あなたのクローンは上流リポジトリのすべてのブランチを持っています。上記のように、あなたのブランチが上流のもので最新になっていることを確認する必要があります:

# change branch e.g. for 2.14 LTR
$ git checkout manual_en_2.14
# get "information" from the manual_en_2.14 branch in upstream repository
$ git fetch upstream manual_en_2.14
# merge update from upstream/manual_en_2.14 to the current local branch
$ git merge upstream/manual_en_2.14
# update **your** remote repository
$ git push origin manual_en_2.14

In this way your local and remote branches for the 2.14 version are up to date with the one of the official upstream repository.

本番ブランチに貢献する

ベースブランチは更新されましたので、次はご自分の貢献を追加する専用のブランチを作成する必要があります。作業は必ずベースブランチ以外のブランチで!常に!

$ git checkout -b myNewBranch
# checkout means go to the branch
# and -b flag creates a new branch if needed, based on current branch
$ git branch
master
manual_en_2.14
* myNewBranch
# a list of existing branch where * means the current branch
# You can now add your contribution, by editing the concerned file
# with any application (in this case, vim is used)
$ vim myFile
# once done
$ git add myFile
$ git commit

commit/pushコマンドについて一言:

  • 一つだけの貢献(原子的変更)コミットするようにしてください、すなわち1つの問題だけアドレス

  • コミットのタイトルおよび説明の中で、変更するものを丁寧に説明するようにしてください。最初の行はタイトルで、大文字で始まり80文字の長さを持っていること、 . では終わらないことが必要です。簡潔に。説明はより長くでき、 . で終了でき、より多くの詳細を与えることができます。

  • 問題を参照するために # を番号とともに使用してください。チケットを修正する場合は Fix でプレフィックスしてください:コミットするとチケットは閉じます。

今、変更は保存されローカルブランチにコミットされましたので、プルリクエストを作成するためにリモートリポジトリに送信する必要があります:

$ git push origin myNewBranch

変更を共有

これであなたのgithubのリポジトリに行って、前のセクションで公開されたように プルリクエストを作成 できます。ご自分のブランチから公式QGIS文書リポジトリ中のターゲットとしているリモートブランチへのPRを作成していることを確認してください。

ローカルおよびリモートリポジトリをクリーンアップ

PRが公式QGIS文書にマージされたらブランチは削除してかまいません。このような方法で多くを作業している場合は、数週間のうちに、役に立たない多くのブランチができるでしょう。だからこのような方法でリポジトリをきれいに保ちましょう:

# delete local branch
$ git branch -d myNewBranch
# Remove your remote myNewBranch by pushing nothing to it
$ git push origin :myNewBranch

そしてローカルリポジトリ中の master ブランチを更新することを忘れずに!