Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
schlosrat committed Jul 4, 2023
2 parents d5321d1 + 748ba7f commit e5d98cd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# schlosrat.github.io
**KSP2 Unofficial API**

This repo contains all the files necessary to build a GitHub Pages site using DocFX to document the KSP2 Application Programming Interface (API). The documentation is composed of two parts: The auto-generated API documentation based on a stripped version of the game's actual source code, plus various articles that relate to understanding and using this documentation.

**NOTE:** There is no actual source code for the game in this repo. The "source" files are all located in the src_stripped folder and only contain the API information stripped from the game's Assembly-CSharp.dll. From this you can see how to call the functions and methods, but not necessarily how they work.

You can make contributions to the KSP2 Unofficial API documentation by forking this repo and editing the stripped C# files in the src_stripped folder, or by adding/updating articles in the articles folder.
4 changes: 2 additions & 2 deletions docfx_project/api/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Unofficial KSP2 API Documentation
The API documented here is based on the 0.1.2 Early Access version of the game. If you're using a different version then the information contained and presented here may be innacurate.
The API documented here is based on the 0.1.3.1 Early Access version of the game. If you're using a different version then the information contained and presented here may be inaccurate.

The basic API documentation found here was automatically generated using DocFX and a stripped version of the KSP 0.1.2 Assembly-CSharp.dll file. Individual pages have been updated in some cases to include additional information useful to modding.
The basic API documentation found here was automatically generated using DocFX and a stripped version of the KSP 0.1.2 Assembly-CSharp.dll file. Individual pages have been updated in some cases to include additional information useful to modding.
18 changes: 10 additions & 8 deletions docfx_project/articles/AddCodeComments.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
# How to Add Documenting (XML) Comments to Code
The first thing you need to do if you've not done this already is to fork this GitHub repo. All the changes you make will be made on your local fork. To incorporate them simply use a Pull Request (PR) from your frok to the main branch of this repo. That said, adding documentng comments is a simple process that goes pretty quickly once you get the hang of it.
The first thing you need to do if you've not done this already is to fork this GitHub repo. All the changes you make will be made on your local fork. To incorporate them simply use a Pull Request (PR) from your fork to the main branch of this repo. That said, adding documenting comments is a simple process that goes pretty quickly once you get the hang of it.

1. Locate the .cs file in the **src_stripped** folder containg the code to which you'd like to add or modify *documentaition generating comments*. Documentation generating comments are those that begin with a tripple slash (///), and they inform the generation of the XML file, so they include XML tags that enable them to be parsed to generate the XML file.
2. Open that file in the editor of your choice. Note that editing in Visual Studio or other similarly capable coding oriented editors may make the following steps easier and automate generation of some basic comments and structure.
1. Locate the .cs file in the **src_stripped** folder containing the code to which you'd like to add or modify *documentation generating comments*. Documentation-generating comments are those that begin with a triple slash (///), and they inform the generation of the XML file, so they include XML tags that enable them to be parsed to generate the XML file.
2. Open that file in the editor of your choice. Note that editing in Visual Studio or other similarly capable coding-oriented editors may make the following steps easier and automate the generation of some basic comments and structure.
3. Navigate to the start of the method or the definition line for the object you would like to document.
4. Insert a new blank line directly above and start a tripple slash (///) comment. If your editor is a sufficiently smart coding-aware editor it may detect that you've started a tripple slash comment and start you out with some comments, but it may also start you out with some misinformation based on the stripped nature of the cs file. The bare minimum for documentation generating comments is a summary block like this. All you need to do is to populate the /// comment line(s) between the `<summary></summary>` tags with information that summarizes what this object is used for or what this method does.
4. Insert a new blank line directly above and start a triple slash (///) comment. If your editor is a sufficiently smart coding-aware editor it may detect that you've started a triple-slash comment and start you out with some comments, but it may also start you out with some misinformation based on the stripped nature of the cs file. The bare minimum for documentation-generating comments is a summary block like this. All you need to do is to populate the /// comment line(s) between the `<summary></summary>` tags with information that summarizes what this object is used for or what this method does.
```cs
/// <summary>
/// Your helpful comments documenting what this is used for or what this does go here!
/// You can have as many lines as you like. Each line defines one paragrah of documentation.
/// You can have as many lines as you like. Each line defines one paragraph of documentation.
/// </summary>
```
5. If the code you're adding *documentation generating comments* to is a method that takes arguments you can document them like this example for a method that takes two input arguments: *newPosition* and *newVelocity*.
```cs
/// <param name="newPosition"></param>
/// <param name="newVelocity"></param>
```
6. If the code you're adding *documentation generating comments* to is a method that returns a result you can document them like this example for a method that returns a *stateData* object.
6. If the code you're adding *documentation generating comments* to is a method or function that returns a result you can document that like the example below for a method that returns a *stateData* object. *NOTE:* If the code you're documenting returns a typed object like a *List<T>*, then you'll want to use some other characters inside the <return> tag in place of the '<' or '>' so that it doesn't interfere with the angle brackets around the return tag. In such cases, you can do this like the example below for *List<ManeuverNodeData>* where '{' and '}' have been used in place of the angle brackets around the return type.
```cs
/// <returns stateData></returns>
...
/// <returns List{ManeuverNodeData}></returns>
```
7. NOTE: All methods in the **src_stripped** folder have been stripped to only `throw null;` consequently, if you're using a code-aware editior it may automatically add a line like this, which **you should delete** as the real code doesn't do this, so it would be incorrect to document it as doing so. DocFx will ignore these lines, but it will also report warnings for them, so please remove them as this aids in making sure the DocFX results are correct.
7. NOTE: All methods in the **src_stripped** folder have been stripped to only `throw null;` consequently if you're using a code-aware editor it may automatically add a line like this, which **you should delete** as the real code doesn't do this, so it would be incorrect to document it as doing so. DocFx will ignore these lines, but it will also report warnings for them, so please remove them as this aids in making sure the DocFX results are correct.
```cs
/// <exception cref="NullReferenceException"></exception>
```

Rinse and repeat for as many objects and methods as you would like to add documenting comments to, then create a PR to get your updates into the main branch of this repo.
Rinse and repeat for as many objects and methods as you would like to add documenting comments to, then create a PR to get your updates into the main branch of this repo.
10 changes: 5 additions & 5 deletions docfx_project/index.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Unofficial **KSP2 API Documentation**
## Site Contents
This site contains (unofficial) documentation for the Kerbal Space Program 2 Application Programming Interface. Although there is no source code here, you will find infomation useful to understanding what the game's internal methods and properties are, and how to access them.
This site contains (unofficial) documentation for the Kerbal Space Program 2 Application Programming Interface. Although there is no source code here, you will find information useful to understanding what the game's internal methods and properties are, and how to access them.

This site is composed of two parts, [Articles](articles/intro.md) containing general information about contributing to this site and modding KSP2, and the [API Documentation](api/index.md) itself based on the 0.1.2 Early Access version of the game. These parts are available in the top bar of any page within this site, and from the Left Side Table of Contents (ToC) menu of this page.
This site is composed of two parts, [Articles](articles/intro.md) containing general information about contributing to this site and modding KSP2, and the [API Documentation](api/index.md) itself based on the 0.1.3.1 Early Access version of the game. These parts are available in the top bar of any page within this site, and from the Left Side Table of Contents (ToC) menu of this page.

The Left Side ToC menu for any page on this site includes a search field that filters the results displayed in the ToC based on what you're looking for. When in the Articles section, the ToC lists the articles available by title, and when in the API Documentation, the ToC shows all the API topic pages releavant to your current search terms. Each API topic page is hyperlinked to other relevant pages to aid site navigation.
The Left Side ToC menu for any page on this site includes a search field that filters the results displayed in the ToC based on what you're looking for. When in the Articles section, the ToC lists the articles available by title, and when in the API Documentation, the ToC shows all the API topic pages relevant to your current search terms. Each API topic page is hyperlinked to other relevant pages to aid site navigation.

## Contributing to This Site
If you would like to contribute to this site, please fork the repo, modify your fork with any additions, modifications, or updates you would like to see, and create pull requests back to the main branch.
If you would like to contribute to this site, please fork the repo, modify your fork with any additions, modifications, or updates you would like to see and create pull requests back to the main branch.

### Quick Start Notes:
1. Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
1. Add images to the *images* folder if the file is referencing an image.
1. Add images to the *images* folder if the file is referencing an image.

0 comments on commit e5d98cd

Please sign in to comment.