Skip to content

Commit

Permalink
Clean up three generate-ref-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
windsonsea committed Jan 3, 2024
1 parent d792a64 commit 4d6a8e5
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 92 deletions.
36 changes: 14 additions & 22 deletions content/en/docs/contribute/generate-ref-docs/contribute-upstream.md
Expand Up @@ -16,11 +16,8 @@ API or the `kube-*` components from the upstream code, see the following instruc
- [Generating Reference Documentation for the Kubernetes API](/docs/contribute/generate-ref-docs/kubernetes-api/)
- [Generating Reference Documentation for the Kubernetes Components and Tools](/docs/contribute/generate-ref-docs/kubernetes-components/)



## {{% heading "prerequisites" %}}


- You need to have these tools installed:

- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
Expand All @@ -38,8 +35,6 @@ API or the `kube-*` components from the upstream code, see the following instruc
For more information, see [Creating a Pull Request](https://help.github.com/articles/creating-a-pull-request/)
and [GitHub Standard Fork & Pull Request Workflow](https://gist.github.com/Chaser324/ce0505fbed06b947d962).



<!-- steps -->

## The big picture
Expand All @@ -51,7 +46,7 @@ from the source code in the [upstream Kubernetes](https://github.com/kubernetes/
When you see bugs in the generated documentation, you may want to consider
creating a patch to fix it in the upstream project.

## Cloning the Kubernetes repository
## Clone the Kubernetes repository

If you don't already have the kubernetes/kubernetes repository, get it now:

Expand All @@ -64,16 +59,16 @@ go get github.com/kubernetes/kubernetes
Determine the base directory of your clone of the
[kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) repository.
For example, if you followed the preceding step to get the repository, your
base directory is `$GOPATH/src/github.com/kubernetes/kubernetes.`
base directory is `$GOPATH/src/github.com/kubernetes/kubernetes`.
The remaining steps refer to your base directory as `<k8s-base>`.

Determine the base directory of your clone of the
[kubernetes-sigs/reference-docs](https://github.com/kubernetes-sigs/reference-docs) repository.
For example, if you followed the preceding step to get the repository, your
base directory is `$GOPATH/src/github.com/kubernetes-sigs/reference-docs.`
base directory is `$GOPATH/src/github.com/kubernetes-sigs/reference-docs`.
The remaining steps refer to your base directory as `<rdocs-base>`.

## Editing the Kubernetes source code
## Edit the Kubernetes source code

The Kubernetes API reference documentation is automatically generated from
an OpenAPI spec, which is generated from the Kubernetes source code. If you
Expand All @@ -84,10 +79,10 @@ The documentation for the `kube-*` components is also generated from the upstrea
source code. You must change the code related to the component
you want to fix in order to fix the generated documentation.

### Making changes to the upstream source code
### Make changes to the upstream source code

{{< note >}}
The following steps are an example, not a general procedure. Details
The following steps are an example, not a general procedure. Details
will be different in your situation.
{{< /note >}}

Expand Down Expand Up @@ -123,12 +118,12 @@ On branch master
modified: staging/src/k8s.io/api/apps/v1/types.go
```

### Committing your edited file
### Commit your edited file

Run `git add` and `git commit` to commit the changes you have made so far. In the next step,
you will do a second commit. It is important to keep your changes separated into two commits.

### Generating the OpenAPI spec and related files
### Generate the OpenAPI spec and related files

Go to `<k8s-base>` and run these scripts:

Expand Down Expand Up @@ -179,7 +174,7 @@ repository and in related repositories, such as
[kubernetes/apiserver](https://github.com/kubernetes/apiserver/blob/master/README.md).
{{< /note >}}

### Cherry picking your commit into a release branch
### Cherry pick your commit into a release branch

In the preceding section, you edited a file in the master branch and then ran scripts
to generate an OpenAPI spec and related files. Then you submitted your changes in a pull request
Expand All @@ -189,7 +184,7 @@ Kubernetes version {{< skew latestVersion >}}, and you want to backport your cha
release-{{< skew prevMinorVersion >}} branch.

Recall that your pull request has two commits: one for editing `types.go`
and one for the files generated by scripts. The next step is to propose a cherry pick of your first
and one for the files generated by scripts. The next step is to propose a cherry pick of your first
commit into the release-{{< skew prevMinorVersion >}} branch. The idea is to cherry pick the commit
that edited `types.go`, but not the commit that has the results of running the scripts. For instructions, see
[Propose a Cherry Pick](https://git.k8s.io/community/contributors/devel/sig-release/cherry-picks.md).
Expand Down Expand Up @@ -220,24 +215,21 @@ the same as the generated files in the master branch. The generated files in the
contain API elements only from Kubernetes {{< skew prevMinorVersion >}}. The generated files in the master branch might contain
API elements that are not in {{< skew prevMinorVersion >}}, but are under development for {{< skew latestVersion >}}.

## Generating the published reference docs
## Generate the published reference docs

The preceding section showed how to edit a source file and then generate
several files, including `api/openapi-spec/swagger.json` in the
`kubernetes/kubernetes` repository.
The `swagger.json` file is the OpenAPI definition file to use for generating
the API reference documentation.

You are now ready to follow the [Generating Reference Documentation for the Kubernetes API](/docs/contribute/generate-ref-docs/kubernetes-api/) guide to generate the
You are now ready to follow the
[Generating Reference Documentation for the Kubernetes API](/docs/contribute/generate-ref-docs/kubernetes-api/)
guide to generate the
[published Kubernetes API reference documentation](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/).



## {{% heading "whatsnext" %}}


* [Generating Reference Documentation for the Kubernetes API](/docs/contribute/generate-ref-docs/kubernetes-api/)
* [Generating Reference Docs for Kubernetes Components and Tools](/docs/contribute/generate-ref-docs/kubernetes-components/)
* [Generating Reference Documentation for kubectl Commands](/docs/contribute/generate-ref-docs/kubectl/)


66 changes: 29 additions & 37 deletions content/en/docs/contribute/generate-ref-docs/kubectl.md
Expand Up @@ -10,8 +10,7 @@ This page shows how to generate the `kubectl` command reference.

{{< note >}}
This topic shows how to generate reference documentation for
[kubectl commands](/docs/reference/generated/kubectl/kubectl-commands)
like
[kubectl commands](/docs/reference/generated/kubectl/kubectl-commands) like
[kubectl apply](/docs/reference/generated/kubectl/kubectl-commands#apply) and
[kubectl taint](/docs/reference/generated/kubectl/kubectl-commands#taint).
This topic does not show how to generate the
Expand All @@ -27,9 +26,9 @@ reference page, see

<!-- steps -->

## Setting up the local repositories
## Set up the local repositories

Create a local workspace and set your `GOPATH`.
Create a local workspace and set your `GOPATH`:

```shell
mkdir -p $HOME/<workspace>
Expand Down Expand Up @@ -58,7 +57,7 @@ Get a clone of the kubernetes/kubernetes repository as k8s.io/kubernetes:
git clone https://github.com/kubernetes/kubernetes $GOPATH/src/k8s.io/kubernetes
```

Remove the spf13 package from `$GOPATH/src/k8s.io/kubernetes/vendor/github.com`.
Remove the spf13 package from `$GOPATH/src/k8s.io/kubernetes/vendor/github.com`:

```shell
rm -rf $GOPATH/src/k8s.io/kubernetes/vendor/github.com/spf13
Expand All @@ -67,22 +66,22 @@ rm -rf $GOPATH/src/k8s.io/kubernetes/vendor/github.com/spf13
The kubernetes/kubernetes repository provides the `kubectl` and `kustomize` source code.

* Determine the base directory of your clone of the
[kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) repository.
For example, if you followed the preceding step to get the repository, your
base directory is `$GOPATH/src/k8s.io/kubernetes.`
The remaining steps refer to your base directory as `<k8s-base>`.
[kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) repository.
For example, if you followed the preceding step to get the repository, your
base directory is `$GOPATH/src/k8s.io/kubernetes`.
The remaining steps refer to your base directory as `<k8s-base>`.

* Determine the base directory of your clone of the
[kubernetes/website](https://github.com/kubernetes/website) repository.
For example, if you followed the preceding step to get the repository, your
base directory is `$GOPATH/src/github.com/<your-username>/website.`
The remaining steps refer to your base directory as `<web-base>`.
[kubernetes/website](https://github.com/kubernetes/website) repository.
For example, if you followed the preceding step to get the repository, your
base directory is `$GOPATH/src/github.com/<your-username>/website`.
The remaining steps refer to your base directory as `<web-base>`.

* Determine the base directory of your clone of the
[kubernetes-sigs/reference-docs](https://github.com/kubernetes-sigs/reference-docs) repository.
For example, if you followed the preceding step to get the repository, your
base directory is `$GOPATH/src/github.com/kubernetes-sigs/reference-docs.`
The remaining steps refer to your base directory as `<rdocs-base>`.
[kubernetes-sigs/reference-docs](https://github.com/kubernetes-sigs/reference-docs) repository.
For example, if you followed the preceding step to get the repository, your
base directory is `$GOPATH/src/github.com/kubernetes-sigs/reference-docs`.
The remaining steps refer to your base directory as `<rdocs-base>`.

In your local k8s.io/kubernetes repository, check out the branch of interest,
and make sure it is up to date. For example, if you want to generate docs for
Expand All @@ -97,7 +96,7 @@ git pull https://github.com/kubernetes/kubernetes {{< skew prevMinorVersion >}}.
If you do not need to edit the `kubectl` source code, follow the instructions for
[Setting build variables](#setting-build-variables).

## Editing the kubectl source code
## Edit the kubectl source code

The kubectl command reference documentation is automatically generated from
the kubectl source code. If you want to change the reference documentation, the first step
Expand All @@ -111,15 +110,14 @@ is an example of a pull request that fixes a typo in the kubectl source code.
Monitor your pull request, and respond to reviewer comments. Continue to monitor your
pull request until it is merged into the target branch of the kubernetes/kubernetes repository.

## Cherry picking your change into a release branch
## Cherry pick your change into a release branch

Your change is now in the master branch, which is used for development of the next
Kubernetes release. If you want your change to appear in the docs for a Kubernetes
version that has already been released, you need to propose that your change be
cherry picked into the release branch.

For example, suppose the master branch is being used to develop Kubernetes
{{< skew currentVersion >}}
For example, suppose the master branch is being used to develop Kubernetes {{< skew currentVersion >}}
and you want to backport your change to the release-{{< skew prevMinorVersion >}} branch. For
instructions on how to do this, see
[Propose a Cherry Pick](https://git.k8s.io/community/contributors/devel/sig-release/cherry-picks.md).
Expand All @@ -132,14 +130,15 @@ milestone in your pull request. If you don't have those permissions, you will
need to work with someone who can set the label and milestone for you.
{{< /note >}}

## Setting build variables
## Set build variables

Go to `<rdocs-base>`. On you command line, set the following environment variables.

* Set `K8S_ROOT` to `<k8s-base>`.
* Set `K8S_WEBROOT` to `<web-base>`.
* Set `K8S_RELEASE` to the version of the docs you want to build.
For example, if you want to build docs for Kubernetes {{< skew prevMinorVersion >}}, set `K8S_RELEASE` to {{< skew prevMinorVersion >}}.
For example, if you want to build docs for Kubernetes {{< skew prevMinorVersion >}},
set `K8S_RELEASE` to {{< skew prevMinorVersion >}}.

For example:

Expand All @@ -162,21 +161,20 @@ cd <rdocs-base>
make createversiondirs
```

## Checking out a release tag in k8s.io/kubernetes
## Check out a release tag in k8s.io/kubernetes

In your local `<k8s-base>` repository, checkout the branch that has
In your local `<k8s-base>` repository, check out the branch that has
the version of Kubernetes that you want to document. For example, if you want
to generate docs for Kubernetes {{< skew prevMinorVersion >}}.0, check out the
`v{{< skew prevMinorVersion >}}` tag. Make sure
you local branch is up to date.
`v{{< skew prevMinorVersion >}}` tag. Make sure your local branch is up to date.

```shell
cd <k8s-base>
git checkout v{{< skew prevMinorVersion >}}.0
git pull https://github.com/kubernetes/kubernetes v{{< skew prevMinorVersion >}}.0
```

## Running the doc generation code
## Run the doc generation code

In your local `<rdocs-base>`, run the `copycli` build target. The command runs as `root`:

Expand Down Expand Up @@ -238,27 +236,21 @@ make container-serve

View the [local preview](https://localhost:1313/docs/reference/generated/kubectl/kubectl-commands/).

## Adding and committing changes in kubernetes/website
## Add and commit changes in kubernetes/website

Run `git add` and `git commit` to commit the files.

## Creating a pull request
## Create a pull request

Create a pull request to the `kubernetes/website` repository. Monitor your
pull request, and respond to review comments as needed. Continue to monitor
your pull request until it is merged.

A few minutes after your pull request is merged, your updated reference
topics will be visible in the
[published documentation](/docs/home).


topics will be visible in the [published documentation](/docs/home).

## {{% heading "whatsnext" %}}


* [Generating Reference Documentation Quickstart](/docs/contribute/generate-ref-docs/quickstart/)
* [Generating Reference Documentation for Kubernetes Components and Tools](/docs/contribute/generate-ref-docs/kubernetes-components/)
* [Generating Reference Documentation for the Kubernetes API](/docs/contribute/generate-ref-docs/kubernetes-api/)


0 comments on commit 4d6a8e5

Please sign in to comment.