docs: add a Module Publish section (#10407)

pull/10426/head
Andreas Heissenberger 2021-06-12 14:12:47 +02:00 committed by GitHub
parent 85e9300a78
commit a71e382b95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 64 additions and 3 deletions

View File

@ -100,7 +100,8 @@ For more details and troubleshooting, please visit the [vab GitHub repository](h
* [Builtin functions](#builtin-functions) * [Builtin functions](#builtin-functions)
* [Printing custom types](#printing-custom-types) * [Printing custom types](#printing-custom-types)
* [Modules](#modules) * [Modules](#modules)
* [Module/package management](#modulepackage-management) * [Manage Packages](#manage-packages)
* [Publish package](#publish-package)
* [Types 2](#types-2) * [Types 2](#types-2)
* [Interfaces](#interfaces) * [Interfaces](#interfaces)
* [Enums](#enums) * [Enums](#enums)
@ -2243,7 +2244,7 @@ fn init() {
The `init` function cannot be public - it will be called automatically. This feature is The `init` function cannot be public - it will be called automatically. This feature is
particularly useful for initializing a C library. particularly useful for initializing a C library.
### Module/package management ### Manage Packages
Briefly: Briefly:
@ -2323,7 +2324,67 @@ v outdated
Modules are up to date. Modules are up to date.
``` ```
You can also add your module to VPM by following the instructions on the website https://vpm.vlang.io/new ### Publish package
1. Put a `v.mod` file inside the toplevel folder of your module (if you
created your module with the command `v new mymodule` or `v init` you already have a v.mod file).
```sh
v new mymodule
Input your project description: My nice module.
Input your project version: (0.0.0) 0.0.1
Input your project license: (MIT)
Initialising ...
Complete!
```
Example `v.mod`:
```v ignore
Module {
name: 'mymodule'
description: 'My nice module.'
version: '0.0.1'
license: 'MIT'
dependencies: []
}
```
Minimal file structure:
```
v.mod
mymodule.v
```
Check that your module name is used in `mymodule.v`:
```v
module mymodule
pub fn hello_world() {
println('Hello World!')
}
```
2. Create a git repository in the folder with the `v.mod` file
(this is not required if you used `v new` or `v init`):
```sh
git init
git add .
git commit -m "INIT"
````
3. Create a public repository on github.com.
4. Connect your local repository to the remote repository and push the changes.
5. Add your module to the public V module registry VPM:
https://vpm.vlang.io/new
You will have to login with your Github account to register the module.
**Warning:** _Currently it is not possibility to edit your entry after submiting.
Check your module name and github url twice as this cannot be changed by you later._
6. The final module name is a combination of your github account and
the module name you provided e.g. `mygithubname.mymodule`.
**Optional:** tag your V module with `vlang` and `vlang-module` on github.com
to allow a better search experiance.
## Types 2 ## Types 2