Важно
Перевод - это работа сообщества : ссылка:Вы можете присоединиться. Эта страница в настоящее время переводится |прогресс перевода|.
1. Пошаговое руководство
Примечание
Хотя для демонстрации процесса используется QGIS-Documentation, все команды и шаги, показанные ниже, применимы и к QGIS-Website.
Если вы читаете эти строки, то наверняка хотите внести свой вклад в написание документации по QGIS и ищете руководство к действию. Вы пришли в нужное место! В этом документе мы расскажем вам о различных способах достижения этой цели, покажем основные шаги, которые необходимо выполнить, приемы, которые можно использовать, и ловушки, о которых следует знать.
Если вам нужна помощь, не стесняйтесь спрашивать в комментариях к отчету о проблеме, которую вы пытаетесь исправить, или пишите в список QGIS-community-team. Ознакомьтесь с общей информацией о поддержке сообщества QGIS <https://qgis.org/resources/support/>`_.
Теперь давайте погрузимся в процесс.
Исходные тексты документации хранятся с помощью системы контроля версий git и доступны на GitHub по адресу https://github.com/qgis/QGIS-Documentation. Список проблем, которые нужно исправить, и функций, которые нужно объяснить, можно найти на https://github.com/qgis/QGIS-Documentation/issues.
Совет
Если вы впервые участвуете в проекте и не знаете, с чего начать, возможно, вам будет интересно разобраться с нашими «приветственными» отчетами о проблемах <https://github.com/qgis/QGIS-Documentation/contribute>`_.
Существует два основных способа изменения файлов, не исключающих друг друга:
1.1. Использование веб-интерфейса GitHub
Веб-интерфейс GitHub позволяет выполнять следующие действия:
редактировать файлы
просмотрите и зафиксируйте изменения
оформите запрос на притяжение, чтобы ваши изменения были добавлены в основной репозиторий
создавать, обновлять или удалять ветви
Если вы еще не знакомы с git и лексикой GitHub, вам стоит прочитать проект GitHub Hello-world, чтобы узнать базовую лексику и действия, которые будут использоваться ниже.
Примечание
Если вы устраняете проблему, о которой было сообщено
Если вы вносите изменения для исправления проблемы, добавьте комментарий к отчету о проблеме, чтобы назначить ее своей. Это не позволит нескольким людям работать над одной проблемой.
1.1.1. Форк QGIS-Документация
Предполагая, что у вас уже есть аккаунт на GitHub <https://github.com/signup>`_, сначала вам нужно форкнуть исходные файлы документации.
Перейдите на страницу QGIS-документация репозитория и нажмите на кнопку в правом верхнем углу.
В вашем аккаунте на GitHub вы найдете репозиторий QGIS-документация (https://github.com/<YourName>/QGIS-Documentation
). Этот репозиторий является копией официального репозитория QGIS-Documentation, где у вас есть полный доступ на запись, и вы можете вносить изменения, не затрагивая официальную документацию.
1.1.2. Внести изменения
Существуют различные способы внесения вклада в документацию QGIS. Ниже мы покажем их по отдельности, но вы можете переключаться с одного процесса на другой без какого-либо ущерба.
Альтернатива 1: Используйте ярлык Редактировать на GitHub
Pages on the QGIS documentation website can be edited quickly and easily by clicking on the
Edit on GitHub
link at the top right of each page,
or in the drop-down menu at the bottom of the left sidebar.
Это откроет файл в ветке
qgis:master
с сообщением в верхней части страницы о том, что у вас нет доступа на запись в это хранилище и ваши изменения будут применены к новой ветке вашего репозитория.Внесите свои изменения. Поскольку документация написана с использованием синтаксиса reStructureText, в зависимости от ваших изменений, вам может понадобиться руководствоваться Руководством по написанию.
Once you have finished modifying the file, press Commit changes… and add a short title explaining your changes. You can also provide a more detailed explanation, if necessary.
Press Propose changes, saving the modifications to your repository. This will generate a dedicated branch (
patch-xxx
) in your repository and the web browser will open the Comparing changes page.If the issue you are addressing does not need any further changes, jump to the Share your changes via Pull Request section below.
Если вы хотите внести дополнительные изменения перед отправкой в QGIS, выполните следующие действия:
Перейдите к вашему форку QGIS-документации (
https://github.com/<YourName>/QGIS-Documentation
)Jump down to the Modify files section below.
Альтернатива 2: Создайте специальную ветку в репозитории документации
Вы можете редактировать файлы прямо из форка Документации QGIS.
First, make sure that your master
branch is up to date with upstream,
i.e. qgis/QGIS-Documentation:master
branch.
To do so:
Перейдите на главную страницу вашего репозитория, то есть
https:/<YourName>/github.com//QGIS-Documentation
. Веткаmaster
должна быть активной с упоминанием того, обновлена ли она доqgis/QGIS-Documentation:master
или нет.Если она имеет коммиты, опережающие ветку восходящего потока, лучше использовать предыдущую альтернативную кнопку быстрого доступа, пока вы не выровняете свою
мастерскую
ветку.Если за ним стоят только коммиты:
Expand the Sync fork drop-down menu on the right. You can:
Compare the branches and see new changes in the upstream branch you do not yet have in yours
Fetch and merge: brings changes from the upstream branch into yours.
Click Fetch and merge: after the process, your branch is mentioned as up to date with
qgis/QGIS-Documentation:master
.
Click on
in the upper left corner of your forked QGIS-Documentation repository and enter a unique name in the text field to create a new branch. It is advised that the name of the new branch relates to the problem you intend to fix. Convenient for identifying the branch later.
Press Create branch <branch_name> from master. The
button should now display branch_name.
You are ready to start new changes on top of your new branch.
Внимание
Вносите изменения в специальную ветку, никогда в мастер
ветку
По правилам, не вносите изменения в свою ветку master
, за исключением тех случаев, когда вы сливаете изменения из ветки master
в свою копию репозитория QGIS-Documentation. Отдельные ветки позволяют вам работать над несколькими проблемами одновременно, не вмешиваясь в работу других веток. Если вы допустите ошибку, вы всегда можете удалить ветку и начать заново, создав новую из основной ветки.
1.1.3. Изменение файлов
Make sure the branch you want to modify is active: its name is displayed in the top left menu or in the page URL.
Browse the source files to the file that needs modifications.
Update the text following the writing guidelines
Once you have finished modifying the file, press Commit changes… and add a short title explaining your changes. You can also provide a more detailed explanation, if necessary.
Make sure Commit directly to the <branch_name> branch is selected.
Press Commit changes to save your modifications in the branch.
To update or add a new image file:
Browse your branch to the folder of the file to update or add.
Top right, use the Managing Screenshots.
menu to select and load files from your drive. You can find hints for formatting an image for the docs atIf a file of the same name already exists, it gets overwritten.
Commit once again your changes to the target branch.
Repeat the previous steps for any other files that need to be updated to fix the issue.
1.1.5. Удалите вашу объединенную ветвь
Вы можете удалить ветку после того, как ваши изменения будут объединены. Удаление старых веток избавит вас от неиспользуемых и устаревших веток в вашем репозитории.
1.2. Using Git command line tools
The GitHub web interface is an easy way to update the QGIS-documentation repo with your contributions, but it doesn’t offer tools to:
group your commits and clean your change history
fix possible conflicts with the main repo
build the documentation to test your changes
You 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.
In the code samples below, lines beginning with $
show commands you should
type while #
are comments.
1.2.1. Local repository
Now you are ready to get a local clone of your QGIS-Documentation repository.
You can clone your QGIS repository using the web URL as follows:
# move to the folder in which you intend to store the local repository
$ cd ~/Documents/Development/QGIS/
$ git clone https://github.com/<YourName>/QGIS-Documentation.git
The former command line is simply an example.
You should adapt both the path and the repository URL, replacing <YourName>
with your github user name.
Check the following:
# Enter the local repository
$ cd ./QGIS-Documentation
$ git remote -v
origin https://github.com/<YourName>/QGIS-Documentation.git (fetch)
origin https://github.com/<YourName>/QGIS-Documentation.git (push)
$ git branch
* master
origin is the name of the remote repository of your QGIS-Documentation repository.
master is the default main branch. You should never use it to contribute! Never!
Alternatively you can clone your QGIS repository using the SSH protocol:
# move to the folder in which you intend to store the local repository
$ cd ~/Documents/Development/QGIS/
$ git clone [email protected]:<YourName>/QGIS-Documentation.git
Совет
Permission denied (publickey) error?
If you get a Permission denied (publickey) error with the former command, there may be a problem with your SSH key. See GitHub help for details.
Check the following if you used the SSH protocol:
# Enter the local repository
$ cd ./QGIS-Documentation
$ git remote -v
origin [email protected]:<YourName>/QGIS-Documentation.git (fetch)
origin [email protected]:<YourName>/QGIS-Documentation.git (push)
$ git branch
* master
You can start to work here but in the long term process you will get a lot of issues when you will push your contribution (called Pull Request in github process) as the master branch of the qgis/QGIS-Documentation repository will diverge from your local/remote repository. You then need to keep track of the main remote repository and work with branches.
1.2.2. Add another remote repository
To be able to follow the work in the main project, add a new remote repository in your local repository. This new remote repository is the QGIS-Documentation repository from QGIS project:
$ git remote add upstream https://github.com/qgis/QGIS-Documentation.git
$ git remote -v
origin https://github.com/<YourName>/QGIS-Documentation.git (fetch)
origin https://github.com/<YourName>/QGIS-Documentation.git (push)
upstream https://github.com/qgis/QGIS-Documentation.git (fetch)
upstream https://github.com/qgis/QGIS-Documentation.git (push)
Similarly, you can use the SSH protocol to add a remote repository in your local repository:
$ 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)
So now you have the choice between two remote repository:
origin to push your local branch in your remote repository
upstream to merge (if you have right to do so) your contribution to the official one OR to update your master branch of local repository from the master branch of the official repository.
Примечание
upstream is just a label, a kind of standard name but you can call it as you want.
1.2.3. Update your base branch
Before working on a new contribution, you should always update your master branch in your local repository. Assuming you are willing to push changes to the testing documentation, run the following command lines:
# switch to master branch (it is easy to forget this step!)
$ git checkout master
# get "information" from the master branch in the 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 (aka <YourName>/QGIS-Documentation)
$ git push origin master
Now you have your local and remote repositories which both have their master
branch up to date with the official master
branch of QGIS-Documentation.
You can start to work on your contribution.
Примечание
Switch the branch if you wish to contribute to released doc
Along with the testing documentation, we continue to fix issues in the
latest release, meaning
that you can also contribute to it. Follow the previous section sample code,
replacing master
with the corresponding branch of the latest documentation.
1.2.4. Contribute to your production branch
Now that your base branch is updated, you need to create a dedicated branch in which you add your contribution. Always work on a branch other than the base branch! Always!
# Create a new branch
$ git checkout -b myNewBranch
# checkout means go to the branch
# and -b flag creates a new branch if needed, based on current branch
# Let's check the list of existing branches (* indicates the current branch)
$ git branch
master
release_2.18
...
* myNewBranch
# You can now add your contribution, by editing the concerned file(s)
# with any application (in this case, vim is used)
$ vim myFile
# once done
$ git add myFile
$ git commit
Few words about commit/push commands:
try to commit only one contribution (atomic change) i.e. address only one issue
try to explain carefully what you change in the title of your commit and in the description. The first line is a title and should start by an upper case letter and have 80 characters length, don’t end with a
.
. Be concise. Your description can be longer, end with a.
and you can give much more details.use a
#
with a number to refer to an issue. Prefix withFix
if you fix the ticket: your commit will close the ticket.
Now that your changes are saved and committed in your local branch, you need to send them to your remote repository in order to create pull request:
$ git push origin myNewBranch
1.2.6. Clean-up your local and remote repository
After your PR has been merged into the official QGIS-Documentation, you can delete your branch. If you work a lot this way, in few weeks you will get a lot of unuseful branches. So keep your repository clean this way:
# delete local branch
$ git branch -d myNewBranch
# Remove your remote myNewBranch by pushing nothing to it
$ git push origin :myNewBranch
And do not forget to update the master
branch in your local repository!
1.3. Дополнительная литература
Other than the Github web interface and the git command line tools exposed above, there are also GUI applications you can use to create and manage your contributions to the documentation.
When the changes in the pull request are conflicting with recent changes pushed to the target branch, the conflicts need to be resolved before a merge is possible:
if the conflict relates to few competing lines, a Resolve conflicts button is available in the GitHub pull request page. Press the button and resolve the issue as explained at Resolving a merge conflict on GitHub
if the conflict involves files renaming or removal, then you’d need to resolve the conflict using git command lines. Typically, you have to first rebase your branch over the target branch using
git rebase targetBranch
call and fix the conflicts that are reported. Read more at Resolving a merge conflict using the command line
Sometimes, at the end of the proofreading process, you may end up with changes split into multiple commits that are not necessarily worth it. Git command lines help you squash these commits to a smaller number and more meaningful commit messages. Some details at Using git rebase on the command line