Cara Membuat dan Menggunakan Alur Kerja Dokumentasi Fedora Lokal

Tim Dokumentasi Fedora Last review: 2024-08-30
Di lingkungan lokal, Anda dapat membuat atau mengedit dokumen Anda secara offline. Anda menggunakan repositori Git lokal yang berisi kumpulan lengkap dokumen dan alat untuk mengedit. Setelah pengeditan selesai, pratinjau dokumen tersebut di versi lokal halaman Docs. Ini adalah cara paling fleksibel untuk bekerja dengan repositori Docs, yang dimungkinkan oleh penyesuaian yang luas terhadap rutinitas kerja individu dan peralatan kerja. Lingkungan penulisan lokal memberikan akses penuh ke semua sumber daya yang Anda gunakan secara rutin di stasiun kerja Anda, sehingga sangat sesuai dengan gaya kerja Anda. Ini sangat cocok untuk pembuatan kumpulan dokumentasi baru sepenuhnya tentang suatu topik atau revisi kumpulan dokumentasi yang sudah ada. Artikel ini mengambil contoh repositori proyek Fedora di GitLab, tetapi proses secara keseluruhan dapat diterapkan untuk proyek Pagure dan GitHub.

Prerequisites

  1. You need to fulfill the basic requirements as specified in Write contributions to Docs.

  2. The workflow uses command line tools in most steps of the process. Having some experience working in the Linux Terminal is therefore necessary or must be learned in parallel.

Setting up an authoring environment

Preparations

  1. Use SSH keys to authenticate to the GitLab remote server.

  2. A GPG (GNU Privacy Guard) key is to sign the commits verified.

On GitLab, go to Preferences - User Settings - Add an SSH Key / a GPG Key

Git and Podman come with Fedora workstation as default. The Podman container is set up automatically.

Create a local subdirectory where the clone of Docs repo is stored

Create the main directory with mkdir DirectoryName

$ mkdir ~/FedoraDocs

Set up the repository

Fork a project

In GitLab, go to the upstream repository and select the Fork button at the top. Select a namespace (your GitLab ID) and a visibility level for the forked project, which creates a fork to your GitLab account.

If you don’t have access to create a project, open an issue ticket in GitLab to create one for you.

Clone the repository

In your forked repo, select the blue Clone button drop-down, and then select Clone with SSH. Copy that link to your clipboard.

Go to your main docs directory, and clone the repo.

$ cd FedoraDocs

When cloning a repository, you can specify the new directory name as an additional argument. This creates a ContributorsGuide subdirectory and clones the repo into that directory.

$ git clone <GIT URL> ContributorsGuide
$ cd ContributorsGuide

Check the current branch, which is main or master.

$ git status

Show all branches on the remote.

$ git branch -v -a

To create a branch and switch to it,

$ git checkout -b <new-branch>

Working on content

Open the file(s) with your choice of text editor, edit, and save.

Sync your fork with the upstream repository

$ git remote -v

This will show the fork in your account as the origin.

Go to the upstream repo, and select the Clone button drop-down, and copy the Clone with SSH info.

$ git remote add upstream <SSH URL>

Run the command below to show both origin and upstream.

$ git remote -v

To keep your fork in sync with upstream,

$ git checkout main
$ git fetch upstream
$ git pull upstream main

This command gets most recent commits from upstream to your local branch.

$ git push origin main

This command pushes your local commits to the main branch of the origin remote.

Run the scripts to preview locally

Go to the the directory where cloned repo is, and run the build scripts in terminal.

$ ./docsbuilder.sh

Preview in your browser using the address localhost:8080

Save your work

To see what has been going on with git add and git commit commands.

$ git status

To add changes which will be committed,

$ git add -A

Alternatively, to add all the files in the current working directory,

$ git add .

Prepare changes for upload, which will open text editor to add commit message.

$ git commit -s

The git log command displays the project history and specific changes.

$ git log

Push changes to your branch in your fork.

$ git push origin <branch-name>

Create merge requests

Go to your fork of the repository in GitLab.

On the left menu, click Merge Requests, and select the blue New merge request in the middle.

When you work in a fork, select your fork of the repository as the source branch.

In the Target branch dropdown list, select the branch from the upstream repository as the target branch.

Click Compare branches and continue.

Select Create merge request.