feat(SoftwareStandards): added svelte scetion, fixed up Rust to more like the Dioxus starter and added template for github actions

This commit is contained in:
darkicewolf50 2025-06-10 14:45:50 -06:00
parent ba54d0b49f
commit 511725110b

View File

@ -9,12 +9,12 @@ In Baja Software it should be belived that at some point you will be gone before
Since you dont know when the end of the software's lifetime is; make life easier on both your future self and new juniors by comments the code, you dont have to comment line by line, but anything that isnt overtly clear should be commented. Since you dont know when the end of the software's lifetime is; make life easier on both your future self and new juniors by comments the code, you dont have to comment line by line, but anything that isnt overtly clear should be commented.
A general guidline to comments: A general guidline to comments:
1. Comment Functions/Methods using the [Standard Function Template](#templates) 1. Comment Functions/Methods using the [Standard Function Template](#templates)
1. Anything unclear to your past self (before creating it) should be commented 1. Anything unclear to your past self (before creating it) should be commented
1. At minimum comment explain what a "block" or scope does 1. At minimum comment explain what a "block" or scope does
1. The rule in highest order can "overshadow" lower rules making them not required, for example a function that adds two integers does not need anything more than a well written [standard function template](#templates) 1. The rule in highest order can "overshadow" lower rules making them not required, for example a function that adds two integers does not need anything more than a well written [standard function template](#templates)
You don't know so make life easier on yourself and new juniors comment on what your code does, it doesn't have to be line by line but at least explain a "block" or a related section of code to the purpose/what it does. You don't know so make life easier on yourself and new juniors comment on what your code does, it doesn't have to be line by line but at least explain a "block" or a related section of code to the purpose/what it does.
## Templates ## Templates
@ -22,7 +22,9 @@ You don't know so make life easier on yourself and new juniors comment on what y
All templates based off JSDoc standard can be found [here](https://jsdoc.app) and markdown All templates based off JSDoc standard can be found [here](https://jsdoc.app) and markdown
### Quick Links ### Quick Links
1. [JavaScipt](#javascript) 1. [JavaScipt](#javascript)
1. [Svelte/Sveltekit]()
1. [Python](#python) 1. [Python](#python)
1. [Rust](#rust) 1. [Rust](#rust)
1. [C++](#c) 1. [C++](#c)
@ -59,7 +61,7 @@ const exampleFunct = (inputVar) => {
// global variable, not strongly typed can be any data type // global variable, not strongly typed can be any data type
var varExample2 = 0; var varExample2 = 0;
// example function does nothing significant // example function does nothing significant
  return 0; return 0;
}; };
/** /**
@ -80,8 +82,76 @@ function exampleFunct2(inputVar) {
var varExample2 = 0; var varExample2 = 0;
// example function does nothing significant // example function does nothing significant
return 0; return 0;
}
```
### Svelte/SvelteKit
<!-- svelte is not a default preview -->
```html
<script>
// comments annotate the line below them
// constant variable cannot change, not strongly typed
const VAREXAMPLE0 = 0;
// local variable, not strongly typed can be any data type
// this is a reactive variable that has a default value of 0
let varExample1 = $state(0);
// global variable, not strongly typed can be any data type
var varExample2 = 0;
let { children, otherProp } = $props();
//Use either sytle, function is preferred, use preferred svelte shorthand when appropriate
/**
* @param {Object} inputVar - one argument into the function should be its name
* @param {number} b - one argument into the function should be its name
* @returns {Promise<number>} c - what the program returns with type
* @description A brief description of what the function does
* @author Name <semiperminant@exmaplemail.com>
// semi-permanent email, do not need to respond but try to be a good alumni
*/
const exampleFunct = (inputVar) => {
// example function does nothing significant
return 0;
}; };
/**
* @param {Object} inputVar - one argument into the function should be its name
* @param {number} b - one argument into the function should be its name
* @returns {Promise<number>} c - what the program returns with type
* @description A brief description of what the function does
* @author Name <semiperminant@exmaplemail.com>
// semi-permanent email, do not need to respond but try to be a good alumni
*/
function exampleFunct2(inputVar) {
// example function does nothing significant
return 0;
}
</script>
<!-- Main -->
<div>
<h1>Does nothing</h1>
{@render children}
</div>
<!-- Main End -->
{#snippet repeatedCode(inputProp)}
<p>{inputprop}</p>
{/snippet}
<style>
/* styles are strongly related unless stated global */
div {
background-color: red;
}
/* every h1 will have a blue background with the user of :global() */
:global(h1) {
background-color: blue;
}
</style>
``` ```
### Python ### Python
@ -123,17 +193,22 @@ The goal of this is to passively train you how to produce comments and code wort
Due to the language's interesting module seperating when creating a large program. All members will be involved in the creation of all functions and how they should be seperated into their groups of related ideas. Due to the language's interesting module seperating when creating a large program. All members will be involved in the creation of all functions and how they should be seperated into their groups of related ideas.
First off the file tree structure will look like this example First off the file tree structure will look like this example
``` ```
src/ src/
├── lib.rs ├── lib.rs
├── front_of_house.rs
└── front_of_house/ └── front_of_house/
├── mod.rs
├── a_different_mod.rs ├── a_different_mod.rs
└── other_module_linked_in_modrs.rs └── other_module_linked_in_modrs.rs
``` ```
These are all related functions in front of house, for small modules do not make a sub directory only large or major functions should be seperated These are all related functions in front of house, for small modules do not make a sub directory only large or major functions should be seperated
Where *`front_of_house.rs`* is like this mod.rs defines all of the other modules/functions/structs (must be defined as pub) in the font_of_house folder/module
Where _`mod.rs`_ is like this
```rust ```rust
//! Describes what front_of_house module provides //! Describes what front_of_house module provides
//! All functionality in other files this serves as a connector //! All functionality in other files this serves as a connector
@ -144,8 +219,9 @@ pub mod a_different_mod;
pub mod other_module_linked_in_modrs; pub mod other_module_linked_in_modrs;
``` ```
Also where *`other_module_linked_in_modrs.rs`* looks like this Also where _`other_module_linked_in_modrs.rs`_ looks like this
```rust
````rust
/// What the function does /// What the function does
/// ///
/// ### Params /// ### Params
@ -157,7 +233,7 @@ Also where *`other_module_linked_in_modrs.rs`* looks like this
/// ///
/// - Description of the return value. /// - Description of the return value.
/// ///
/// ### Example Usage /// # Example Usage
/// ///
/// ```rust /// ```rust
/// // how a user would use this function, replace ex_crate with actual path to use function /// // how a user would use this function, replace ex_crate with actual path to use function
@ -165,7 +241,7 @@ Also where *`other_module_linked_in_modrs.rs`* looks like this
/// let result = crate::front_of_house::other_module_linked_in_modrs::example_funct(5, 10); /// let result = crate::front_of_house::other_module_linked_in_modrs::example_funct(5, 10);
/// assert_eq!(result, 15); /// assert_eq!(result, 15);
/// ``` /// ```
/// ### Author (s) /// # Author (s)
/// ///
/// - Name <semiperminant@exmaplemail.com> /// - Name <semiperminant@exmaplemail.com>
/// - Another Example <different@examplemail.com> /// - Another Example <different@examplemail.com>
@ -177,7 +253,7 @@ pub fn example_funct(input_var: i32, b: i32) -> i32 {
// example function does nothing significant // example function does nothing significant
var_example + input_var + b var_example + input_var + b
} }
``` ````
One all of the main modules have been decided upon a senior member or lead will be assigned to that module will then be responsible and will break the module into sub components to assign out to implement. One all of the main modules have been decided upon a senior member or lead will be assigned to that module will then be responsible and will break the module into sub components to assign out to implement.
@ -240,6 +316,7 @@ int exampleFunct (int inputVar) {
``` ```
### Java/C# ### Java/C#
```java ```java
// these languages is cursed and full of boilerplate // these languages is cursed and full of boilerplate
// use anything else if you can // use anything else if you can
@ -248,19 +325,23 @@ int exampleFunct (int inputVar) {
``` ```
### Golang ### Golang
```golang ```golang
// I dont know // I dont know
// you can add standard here just make it similar to the rest // you can add standard here just make it similar to the rest
``` ```
### Lua ### Lua
```lua ```lua
-- I dont know -- I dont know
-- you can add standard here just make it similar to the rest -- you can add standard here just make it similar to the rest
``` ```
### Terraform ### Terraform
This will probably only used for cloud applications This will probably only used for cloud applications
```terraform ```terraform
<!-- <!--
I dont know I dont know
@ -269,16 +350,21 @@ This will probably only used for cloud applications
``` ```
### HTML ### HTML
This is the same as any other page, not unique, should still vet in a html validator/best practices This is the same as any other page, not unique, should still vet in a html validator/best practices
author goes in human.txt, for more info please see [here](https://humanstxt.org) author goes in human.txt, for more info please see [here](https://humanstxt.org)
```html ```html
<!doctype html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Our Funky HTML Page</title> <title>Our Funky HTML Page</title>
<meta name="description" content="Our first page"> <meta
<meta name="keywords" content="html tutorial template"> name="description"
content="Our first page" />
<meta
name="keywords"
content="html tutorial template" />
</head> </head>
<body> <body>
Content goes here. Content goes here.
@ -287,10 +373,13 @@ author goes in human.txt, for more info please see [here](https://humanstxt.org)
``` ```
### JSON, YAML, XML, CSS ### JSON, YAML, XML, CSS
These are more like data types/file format, follow rules of the language These are more like data types/file format, follow rules of the language
### Bash ### Bash
Always starts with a shebang Always starts with a shebang
```bash ```bash
#! #!
echo "Hello World!" echo "Hello World!"
@ -300,6 +389,78 @@ echo "Hello World!"
### Github Actions ### Github Actions
Please find example in any baja repo under .github/workflows/*.yaml Please find example in any baja repo under .github/workflows/\*.yaml
star is a wildcard and in this case represents any name of the file star is a wildcard and in this case represents any name of the file
Do not feel bad using AI for this, but all of these are linux commands for the most part
```yaml
# name of the workflow.
# this is optional.
name: Cloud Actions
# events that will trigger this workflow.
# here, we only have "pull_request", so the workflow will run
# whenever we create a pull request.
# other examples: [push] and [pull_request, push]
on:
pull_request:
push:
branches:
- master
# each workflow must have at least one job.
# jobs run in parallel by default (we can change that).
# each job groups together a series of steps to accomplish a purpose.
jobs:
# name of the job
ruffLint:
# the platform or OS that the workflow will run on.
runs-on: ubuntu-latest
# series of steps to finish the job.
steps:
# name of the step.
# steps run sequentially.
# this is optionale
- name: checkout
# each step can either have "uses" or "run".
# "uses" run an action written somewhere other than this workflow .
# usually from the community.
# this action checks out the repo code to the runner (instance)
# running the action
uses: actions/checkout@v3
# another step.
# this step runs a bash (Ubuntu's default shell) command
- name: install ruff
run: pip install ruff
- name: Lint
run: ruff check --ignore E402
Dockerhub:
runs-on: ubuntu-latest
needs: ruffLint # will only run if linter is successful
if: ${{ github.ref == 'refs/heads/master' || github.event.pull_request.merged == true }} # Runs if it's a push to 'main' or a merged PR to 'main'
steps:
- name: checkout
uses: actions/checkout@v3
- name: Login to Dockerhub # log into docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }} # Using secret for Docker username
password: ${{ secrets.DOCKER_PASSWORD }} # Using secret for Docker password
id: docker-login
- name: build container image # build the container
run: docker compose build --no-cache
id: docker-build
- name: Upload to Dockerhub
run: docker push darkicewolf50/uofcbajacloud:latest
if: ${{ steps.docker-login.outcome == 'success' && steps.docker-build.outcome == 'success' }}
```