|
2 | 2 |
|
3 | 3 | Thank you for your interest in contributing! FEAScript is in early development, with continuous additions of new features and improvements. To ensure a smooth and collaborative development process, please review and follow the guidelines below.
|
4 | 4 |
|
5 |
| -## Contribution Guidelines |
6 |
| - |
7 |
| -1. **Development Tools:** |
8 |
| - We recommend using [Visual Studio Code](https://code.visualstudio.com/) with the [Prettier plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for automatic code formatting. Additionally, use a **110-character line width** to maintain consistent formatting. |
9 |
| - |
10 |
| -2. **Coding Style:** |
11 |
| - Observe the code near your intended changes and aim to preserve that style in your modifications. |
12 |
| - |
13 |
| -3. **Variable Naming:** |
14 |
| - Use [camelCase](https://en.wikipedia.org/wiki/Camel_case) formatting for variable names throughout the code. |
15 |
| - |
16 |
| -4. **File Naming:** |
17 |
| - All JavaScript source files in FEAScript end with the suffix `Script` before the `.js` extension (e.g., `loggingScript.js`, `meshGenerationScript.js`, `newtonRaphsonScript.js`). This is an explicit, project‑level stylistic choice to: |
18 |
| - |
19 |
| - - Visually distinguish internal FEAScript modules from third‑party or external library files. |
20 |
| - - Keep historical and stylistic consistency across the codebase. |
21 |
| - |
22 |
| - Exceptions: |
23 |
| - |
24 |
| - - Public entry file: `index.js` (standard entry point convention). |
25 |
| - - Core model file: `FEAScript.js` (matches the library name; appending "Script" would be redundant). |
26 |
| - |
27 |
| -5. **File Structure:** |
28 |
| - All files in the FEAScript-core codebase should follow this structure: |
29 |
| - |
30 |
| - 1. **Banner**: All files start with the FEAScript ASCII art banner. |
31 |
| - 2. **Imports**: |
32 |
| - - External imports (from npm packages) first, alphabetically ordered. |
33 |
| - - Internal imports next, grouped by module/folder. |
34 |
| - 3. **Classes/Functions**: Implementation with proper JSDoc comments. |
35 |
| - |
36 |
| - Example: |
37 |
| - |
38 |
| - ```javascript |
39 |
| - // ______ ______ _____ _ _ // |
40 |
| - // | ____| ____| /\ / ____| (_) | | // |
41 |
| - // | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ // |
42 |
| - // | __| | __| / /\ \ \___ \ / __| __| | _ \| __| // |
43 |
| - // | | | |____ / ____ \ ____) | (__| | | | |_) | | // |
44 |
| - // |_| |______/_/ \_\_____/ \___|_| |_| __/| | // |
45 |
| - // | | | | // |
46 |
| - // |_| | |_ // |
47 |
| - // Website: https://feascript.com/ \__| // |
48 |
| - |
49 |
| - // External imports |
50 |
| - import { mathLibrary } from "math-package"; |
51 |
| - |
52 |
| - // Internal imports |
53 |
| - import { relatedFunction } from "../utilities/helperScript.js"; |
54 |
| - |
55 |
| - /** |
56 |
| - * Class to handle specific functionality |
57 |
| - */ |
58 |
| - export class MyClass { |
59 |
| - /** |
60 |
| - * Constructor to initialize the class |
61 |
| - * @param {object} options - Configuration options |
62 |
| - */ |
63 |
| - constructor(options) { |
64 |
| - // Implementation |
65 |
| - } |
66 |
| - |
67 |
| - /** |
68 |
| - * Function to perform a specific action |
69 |
| - * @param {number} input - Input value |
70 |
| - * @returns {number} Processed result |
71 |
| - */ |
72 |
| - doSomething(input) { |
73 |
| - // Implementation |
74 |
| - return input * DEFAULT_VALUE; |
75 |
| - } |
76 |
| - } |
77 |
| - ``` |
78 |
| - |
79 |
| -6. **Branching & Workflow:** |
80 |
| - To contribute a new feature or fix: |
81 |
| - |
82 |
| - - Do not commit directly to `main`. |
83 |
| - - Instead, create a short‑lived branch: |
84 |
| - - `feature/<topic>` for new functionality |
85 |
| - - `fix/<issue>` for bug fixes |
86 |
| - |
87 |
| - External contributors: |
88 |
| - |
89 |
| - 1. Fork the repo. |
90 |
| - 2. Branch from `main` in your fork. |
91 |
| - 3. Push and open a PR from your fork’s branch into `main`. |
92 |
| - |
93 |
| -7. **Local Testing:** |
94 |
| - Before submitting a pull request, test your modifications by running the FEAScript library from a local directory. For example, you can load the library in your HTML file as follows: |
95 |
| - |
96 |
| - ```javascript |
97 |
| - import { FEAScriptModel, plotSolution, printVersion } from "[USER_DIRECTORY]/FEAScript-core/src/index.js"; |
98 |
| - ``` |
99 |
| - |
100 |
| - FEAScript can be run on a local server. To start a local server, you can use [Python HTTP Server](https://docs.python.org/3/library/http.server.html): |
101 |
| - |
102 |
| - ```bash |
103 |
| - python -m http.server |
104 |
| - ``` |
105 |
| - |
106 |
| - where the server will be available at `http://127.0.0.1:8000/`. Static file server npm packages like [serve](https://github.com/vercel/serve#readme) and [Vite](https://vite.dev/) can also be used. |
| 5 | +## Contents |
| 6 | + |
| 7 | +- [Development Environment & Coding Style](#development-environment--coding-style) |
| 8 | +- [Variable & File Naming](#variable--file-naming) |
| 9 | +- [File Structure](#file-structure) |
| 10 | +- [Branching & Workflow](#branching--workflow) |
| 11 | +- [Local Testing](#local-testing) |
| 12 | + |
| 13 | +## Development Environment & Coding Style |
| 14 | + |
| 15 | +- Use [Visual Studio Code](https://code.visualstudio.com/) with the [Prettier plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for automatic code formatting |
| 16 | +- Use a **110-character line width** to maintain consistent formatting |
| 17 | +- Observe the code near your intended changes and aim to preserve that style in your modifications |
| 18 | + |
| 19 | +## Variable & File Naming |
| 20 | + |
| 21 | +- Use [camelCase](https://en.wikipedia.org/wiki/Camel_case) formatting for variable names throughout the code |
| 22 | +- All JavaScript source files in FEAScript end with the suffix `Script` before the `.js` extension (e.g., `loggingScript.js`, `meshGenerationScript.js`, `newtonRaphsonScript.js`). This is an explicit, project‑level stylistic choice to: |
| 23 | + - Visually distinguish internal FEAScript modules from third‑party or external library files |
| 24 | + - Keep historical and stylistic consistency across the codebase |
| 25 | + |
| 26 | +### Exceptions |
| 27 | + |
| 28 | +- Public entry file: `index.js` (standard entry point convention) |
| 29 | +- Core model file: `FEAScript.js` (matches the library name; appending "Script" would be redundant) |
| 30 | + |
| 31 | +## File Structure |
| 32 | + |
| 33 | +All files in the FEAScript-core codebase should follow this structure: |
| 34 | + |
| 35 | +1. Banner: All files start with the FEAScript ASCII art banner |
| 36 | +2. Imports: |
| 37 | + - External imports first, alphabetically ordered |
| 38 | + - Internal imports next, grouped by module/folder |
| 39 | +3. Classes/Functions: Implementation with proper JSDoc comments |
| 40 | + |
| 41 | +Example: |
| 42 | + |
| 43 | +```javascript |
| 44 | +// ______ ______ _____ _ _ // |
| 45 | +// | ____| ____| /\ / ____| (_) | | // |
| 46 | +// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ // |
| 47 | +// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| // |
| 48 | +// | | | |____ / ____ \ ____) | (__| | | | |_) | | // |
| 49 | +// |_| |______/_/ \_\_____/ \___|_| |_| __/| | // |
| 50 | +// | | | | // |
| 51 | +// |_| | |_ // |
| 52 | +// Website: https://feascript.com/ \__| // |
| 53 | + |
| 54 | +// External imports |
| 55 | +import { mathLibrary } from "math-package"; |
| 56 | + |
| 57 | +// Internal imports |
| 58 | +import { relatedFunction } from "../utilities/helperScript.js"; |
| 59 | + |
| 60 | +/** |
| 61 | + * Class to handle specific functionality |
| 62 | + */ |
| 63 | +export class MyClass { |
| 64 | + /** |
| 65 | + * Constructor to initialize the class |
| 66 | + * @param {object} options - Configuration options |
| 67 | + */ |
| 68 | + constructor(options) { |
| 69 | + // Implementation |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Function to perform a specific action |
| 74 | + * @param {number} input - Input value |
| 75 | + * @returns {number} Processed result |
| 76 | + */ |
| 77 | + doSomething(input) { |
| 78 | + // Implementation |
| 79 | + return input * DEFAULT_VALUE; |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +## Branching & Workflow |
| 85 | + |
| 86 | +To contribute a new feature or fix: |
| 87 | + |
| 88 | +- Do not commit directly to `main` |
| 89 | +- Instead, create a short‑lived branch: |
| 90 | + - `feature/<topic>` for new functionality |
| 91 | + - `fix/<issue>` for bug fixes |
| 92 | + |
| 93 | +External contributors: |
| 94 | + |
| 95 | +1. Fork the repo |
| 96 | +2. Branch from `main` in your fork |
| 97 | +3. Push and open a PR from your fork’s branch into `main` |
| 98 | + |
| 99 | +## Local Testing |
| 100 | + |
| 101 | +Before submitting a pull request, test your modifications by running the FEAScript library from a local directory. For example, you can load the library in your HTML file as follows: |
| 102 | + |
| 103 | +```javascript |
| 104 | +import { FEAScriptModel, plotSolution, printVersion } from "[USER_DIRECTORY]/FEAScript-core/src/index.js"; |
| 105 | +``` |
| 106 | + |
| 107 | +FEAScript can be run on a local server. Ensure you start the server from the workspace root directory, where both `FEAScript-core` and `FEAScript-website` folders are located, to correctly resolve relative paths in the HTML files. To start a local server, you can use [Python HTTP Server](https://docs.python.org/3/library/http.server.html): |
| 108 | + |
| 109 | +```bash |
| 110 | +python -m http.server |
| 111 | +``` |
| 112 | + |
| 113 | +where the server will be available at `http://127.0.0.1:8000/`. Static file server npm packages like [serve](https://github.com/vercel/serve#readme) and [Vite](https://vite.dev/) can also be used. |
0 commit comments