Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: make a Sphinx guiding. #271

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions docs/source/For Developer/A Completed Pull Request.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ Takeaway:

<img width="1174" alt="image" src="https://user-images.githubusercontent.com/47497750/236991014-7c17248c-54cc-41f0-af15-796a67de5307.png">

3. Use `git clone <url>` to clone the remote codebase into your local machine through the command line. No worry if your shell (command line) looks different from mine (The operations are same in the Mac and Windows systems).
3. Use `git clone <url>` to clone the remote codebase into your local machine through the command line. No worry if your shell (command line) looks different from mine (The operations are same in the Mac and Windows systems. Note that the operations are same in both CMD and Powershell so we only show the CMD).

<img width="920" alt="image" src="https://user-images.githubusercontent.com/47497750/236991322-843c9497-3c32-42d0-a564-1979e093a8d1.png">

<img width="800" alt="image" src="https://user-images.githubusercontent.com/66153455/277151066-7b12f1c6-a507-41a5-873d-4887bf616508.jpg">

4. Switch into **geochemistrypi** repository. Activate your virtual environment (**venv** or **conda**). In this case, I use conda to set up. It is a good habit to use a specific virtual environment for a specific Python project. Then, use `pip install -r requirements.txt` to download the dependencies.

<img width="921" alt="image" src="https://user-images.githubusercontent.com/47497750/237021355-0fff7b74-ebd8-47f6-8c76-8918b11fc8ec.png">
Expand All @@ -27,7 +29,7 @@ Takeaway:

<img width="920" alt="image" src="https://user-images.githubusercontent.com/47497750/237022518-7e0dfa23-7b49-46f3-adf2-ec1f83651f44.png">

<img width="920" alt="image" src="https://user-images.githubusercontent.com/66153455/262966493-d147a599-4b18-4974-80e3-00b1f620c96b.jpg">
<img width="500" alt="image" src="https://user-images.githubusercontent.com/66153455/262966493-d147a599-4b18-4974-80e3-00b1f620c96b.jpg">

6. Use **Visual Studio Code** (Recommended IDE) to open the codebase and don't forget to activate your virtual environment as the picture shows below.

Expand All @@ -37,7 +39,7 @@ Takeaway:

<img width="1219" alt="image" src="https://user-images.githubusercontent.com/47497750/237028303-e3edf748-2f76-40a3-8247-3869656dfc88.png">

<img width="1219" alt="image" src="https://user-images.githubusercontent.com/66153455/262966498-aaa905ab-63a5-4231-845d-b217180b998f.jpg">
<img width="500" alt="image" src="https://user-images.githubusercontent.com/66153455/262966498-aaa905ab-63a5-4231-845d-b217180b998f.jpg">

8. Do some modifications on the codebase. For example, in this case, I update the badge information of READM.md.

Expand All @@ -47,16 +49,22 @@ Takeaway:

<img width="1438" alt="image" src="https://user-images.githubusercontent.com/47497750/237053725-303b6c15-5939-441e-8bee-2d322c2e8019.png">

<img width="700" alt="image" src="https://user-images.githubusercontent.com/66153455/277151322-03292deb-98bf-46f2-8ceb-e4feaeed016f.jpg">

10. It is a good habit to use `git diff <filename>` check whether the changed content on that specific files respectively is what you desire to make. After enter the command, the console will switch into **diff display**. In **diff displays** , press the keybord `j` to scroll down and press the keyboard `k` to scroll up. `+` refers to the line added while `-` refers to the line deleted. Press the keyboard `q` to exit from the **diff display** after checking.

<img width="1200" alt="image" src="https://user-images.githubusercontent.com/47497750/237054080-39198eac-e804-41db-b672-aece0417fe38.png">

<img width="1274" alt="image" src="https://user-images.githubusercontent.com/47497750/237013451-f7bd73f8-6b3f-4781-8954-5aaf1e171f1f.png">
<img width="1200" alt="image" src="https://user-images.githubusercontent.com/47497750/237013451-f7bd73f8-6b3f-4781-8954-5aaf1e171f1f.png">

<img width="700" alt="image" src="https://user-images.githubusercontent.com/66153455/277151323-dc15d98a-b79d-4a2e-8c99-83f706c02df4.jpg">

11. Use `git add <filename>` to staged the files for commit.

<img width="1202" alt="image" src="https://user-images.githubusercontent.com/47497750/237054509-e8418115-23c3-49c7-8690-51dc31d2aed1.png">

<img width="1202" alt="image" src="https://user-images.githubusercontent.com/66153455/277151540-5d74f7d4-583d-4003-ae36-b308d90d1dce.jpg">

12. Use `git commit -m "tag: message"` to make a local commit. It is a good habit to follow up the principle that one commit for one functionality implementation or one optimization or one bug fix. It is allowed to push multiple commits to the remote codebase with one pull request.

Please include the following tags in the beginning of your commit message to make more organized commits and PRs. It would tell exactly what use it is in this commit.
Expand All @@ -76,6 +84,8 @@ Takeaway:

<img width="1204" alt="image" src="https://user-images.githubusercontent.com/47497750/237055438-38e60ffc-a54d-4a25-82d3-d5e8b33357d6.png">

<img width="1204" alt="image" src="https://user-images.githubusercontent.com/66153455/277151327-f21344c7-2c64-4535-bd39-7259ad123f5d.jpg">

13. Continuous Integration (CI): In our codebase, we set up a pre-commit locally before. Normally, it will automatically check code grammar and correct code styles for your commited code.

(1) In this **successful case**, it indicates that everything works well. No code grammar mistake and code style conforms to the configuration. Hence, no need to do further, you can push the local commit to remote codebase in the GitHub.
Expand All @@ -86,20 +96,28 @@ Takeaway:

<img width="1160" alt="Pasted Graphic 9" src="https://user-images.githubusercontent.com/47497750/237057185-f43b9867-7f42-4505-a90e-0c954923a1da.png">

<img width="1160" alt="Pasted Graphic 9" src="https://user-images.githubusercontent.com/66153455/277152562-51f9ff53-8468-4999-b2ed-10b17c9a2895.jpg">

The next step is to use `git status` and `git diff` to check the details in the corrected files to see what CI tool has done for you.

<img width="627" alt="Pasted Graphic 13" src="https://user-images.githubusercontent.com/47497750/237058359-6616e9aa-ad44-488f-bfea-b290a6c8cb08.png">

<img width="576" alt="Pasted Graphic 14" src="https://user-images.githubusercontent.com/47497750/237058693-95e9b454-92be-4e47-a7ab-9031c7645849.png">

<img width="1200" alt="Pasted Graphic 14" src="https://user-images.githubusercontent.com/66153455/277152566-e7cec8f4-00ef-43e1-ad40-43a62995e458.jpg">

You would see that you need to use `git add` again. Because CI tool has modified your code , you need to do a standard git commit process again.

<img width="800" alt="Pasted Graphic 16" src="https://user-images.githubusercontent.com/47497750/237059215-08ef553a-be5e-46bf-9c5c-e76342773d8b.png">

<img width="800" alt="Pasted Graphic 16" src="https://user-images.githubusercontent.com/66153455/277152576-8af5435d-f305-47f0-b418-d870f6523a97.jpg">

Again, you need to run `git commit` again. Just use the previous same command. Now, it passes! Fancy is it? Until now, you are allowed to push the local commit to remote codebase in the GitHub.

<img width="1109" alt="Pasted Graphic 17" src="https://user-images.githubusercontent.com/47497750/237059295-42b855e9-f70a-4894-8e34-0b406e1d9f53.png">

<img width="1109" alt="Pasted Graphic 17" src="https://user-images.githubusercontent.com/66153455/277152573-4b91fd02-cd4e-4051-9cf9-36f9aaa6eeef.jpg">

14. Back to the **successful case**. Now, it is time to push your local **dev/Sany** branch to the remote **dev/Sany** branch. It may not created yet, but no worried, it will be shown later. Firstly, use `git pull origin main --rebase`. This command pulls the latest changes from the remote **main** branch and applies them to your local **dev/Sany** branch, while also rebasing your local changes on top of the new changes from the remote.

(1) **No conflict case**: In this example, it indicates that there is no conflict with the remote **main** branch. Quite normally, sometimes, when you are coding in your own branch, the remote **main** branch is far ahead of yours. It is likely that there are conflicts existing so you need to resolve the conflicts before merge your remote **dev/Sany** branch into remote **main** branch.
Expand Down Expand Up @@ -134,6 +152,8 @@ Takeaway:

<img width="816" alt="Pasted Graphic 5" src="https://github.com/ZJUEarthData/geochemistrypi/assets/47497750/c286eb02-91e4-4927-8b69-981b6aa7a902">

<img width="1200" alt="Pasted Graphic 5" src="https://user-images.githubusercontent.com/66153455/277152581-3ac19fc4-96e4-424f-82e5-17892204cdc5.jpg">

Once you finish pushing, you can use `git stash pop` to bring back the modified files into your working directory. For more information about **git stash** , plz google it.

<img width="816" alt="Pasted Graphic 6" src="https://github.com/ZJUEarthData/geochemistrypi/assets/47497750/6472df94-8d65-45aa-b787-1848966fe90d">
Expand Down
54 changes: 54 additions & 0 deletions docs/source/For Developer/Common Operations in Sphinx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Common Operations in Sphinx

Takeaway
+ Installation - PyPi(windpows, CMD)
+ Installation - PyPi(windpows, Powershell)
+ Installation - Conda(windpows, waiting for update)
+ Installation - PyPi(MacOS/Linux, waiting for update)
+ Installation - Conda(MacOS/Linux, waiting for update)
+ Fast Build Sphinx

1. Open the **CMD** terminal in the **Windows** and install the **Sphinx** package by the **Pypi**. The first step is to enter the **geochemistrypi** file and activate the virtual envirnment. Then use the **pip** command to install the **Sphinx** package.

```None
cd geochemistry
conda activate your_env # Conda with Vscode is the most recommended way
pip install -U sphinx
```
<img width="920" alt="image" src="https://user-images.githubusercontent.com/66153455/265470689-396caf7f-4a7d-4776-aedf-b86bc6208549.jpg">

<img width="920" alt="image" src="https://user-images.githubusercontent.com/66153455/265470690-ae786ecf-f39e-4993-8ae2-409b388282b0.jpg">

2. Open the **Powershell** terminal in the **Windows** and install the **Sphinx** package by the **Pypi**. The steps are close to the CMD way.

<img width="920" alt="image" src="https://user-images.githubusercontent.com/66153455/265470688-9a4f24ea-ce70-4608-ac70-c270f330e14f.jpg">

<img width="920" alt="image" src="https://user-images.githubusercontent.com/66153455/265470678-21ae50d6-6934-4adc-bd42-7952cd3f661a.jpg">

3. The ***Sphinx*** ia a convenient tool for documentations in the projects managemnet. From the *[Getting start](https://www.sphinx-doc.org/en/master/tutorial/getting-started.html)* of the official ***[Sphinx documentations](https://www.sphinx-doc.org/en/master/index.html)***, we'd better to set a *README.rst* file in a project like:

<center class="half">
<img width="150" height="200" alt="image" src="https://user-images.githubusercontent.com/66153455/265570728-08acdf8d-0e7f-4935-a9e1-05693035c1e0.jpg"><img width="500" height="200" alt="image" src="https://user-images.githubusercontent.com/66153455/265570736-24ed3ab1-6b49-4677-847e-0a55fe2e548f.jpg">
</center>

This time I just make a trail docs file. In fact, in a real project, we must write down the descriptions of the project.

In addition, the *[Creating the documentation layout](https://www.sphinx-doc.org/en/master/tutorial/getting-started.html)* is also useful to set up a layout. The specific code is just:

```None
sphinx-quickstart docs
```

*In this doc, the consequent screenshots are gained on the Powershell/Windows platform. The fast layout would be like:*

<img width="920" alt="image" src="https://user-images.githubusercontent.com/66153455/265570738-a464efef-5187-499b-8c31-9dfcdac43104.jpg">

As you can see, after you write down the commands, some Chinese reflects are shown in the screen. The root can be set as you wish.

*Then several parameters can be set in the Terminal:*

<img width="920" alt="image" src="https://user-images.githubusercontent.com/66153455/265570740-c6cf9f23-1a53-47fa-8503-cf7c51f403a3.jpg">

*Congratulations!Now you can start write in the index.rst file:*

<img width="920" alt="image" src="https://user-images.githubusercontent.com/66153455/265577459-cdc9cb67-92e4-4ed5-a161-b04f8d988438.jpg">
20 changes: 19 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,31 @@ Welcome to Geochemistry π
:caption: For Developer

Developer Guide <For Developer/Developer Guide/Developer Manual.md>
Contributing <contributing.rst>
Docs Link <For Developer/Developer Docs link.md>

Local Deployment <For Developer/Local Deployment.md>
Docker Deployment <For Developer/Docker Deployment.md>
Algorithm Functionality Addition <For Developer/Algorithm Functionality Addition Procedure_geochemistrypi 0.2.0_CN/data_mining_geochemistrypi_020.md>
Complete Pull Request <For Developer/A Completed Pull Request.md>

.. toctree::
:maxdepth: 4
:caption: For Developer

Developer Guide <For Developer/Developer Guide/Developer Manual.md>
Docs Link <For Developer/Developer Docs link.md>

Local Deployment <For Developer/Local Deployment.md>
Docker Deployment <For Developer/Docker Deployment.md>
Algorithm Functionality Addition <For Developer/Algorithm Functionality Addition Procedure_geochemistrypi 0.2.0_CN/data_mining_geochemistrypi_020.md>
Complete Pull Request <For Developer/A Completed Pull Request.md>

.. toctree::
:maxdepth: 3
:caption: Contributor

Contributing <contributing.rst>

Indices and tables
==================

Expand Down