| 1 | # Website Local Documentation Development Guide |
| 2 | |
| 3 | This guide explains how to set up and run the documentation site locally for |
| 4 | development purposes. |
| 5 | |
| 6 | ## Prerequisites |
| 7 | |
| 8 | * Ruby (version 2.7.0 or higher) |
| 9 | |
| 10 | * Bundler |
| 11 | * Git |
| 12 | * Node/npm |
| 13 | * A GitHub account with a fork of the fheroes2 repository |
| 14 | |
| 15 | ### macOS Users |
| 16 | |
| 17 | If you're on macOS, you can install the required development tools using the |
| 18 | provided Brewfile: |
| 19 | |
| 20 | ```bash |
| 21 | # Install the development tools using brew bundle |
| 22 | brew bundle --file=script/macos/Brewfile.dev_tools |
| 23 | ``` |
| 24 | |
| 25 | This will install the necessary tools to assist with formatting and for linting |
| 26 | source files. |
| 27 | |
| 28 | ## Setting Up Local Development Environment |
| 29 | |
| 30 | 1. Clone your fork of the repository: |
| 31 | |
| 32 | ```bash |
| 33 | git clone https://github.com/<YOUR_USERNAME>/fheroes2.git |
| 34 | cd fheroes2/docs |
| 35 | ``` |
| 36 | |
| 37 | 2. Copy the development Gemfile to enable local development: |
| 38 | |
| 39 | ```bash |
| 40 | cp Gemfile.dev Gemfile |
| 41 | ``` |
| 42 | |
| 43 | > **Note** |
| 44 | > While the gem in this file may eventually be deprecated, it's currently the |
| 45 | > simplest way to enable local development of the GitHub Pages site. As such, |
| 46 | > the Gemfile should not be committed into the repo. |
| 47 | |
| 48 | 3. Install the required Ruby dependencies: |
| 49 | |
| 50 | ```bash |
| 51 | bundle install |
| 52 | ``` |
| 53 | |
| 54 | 4. Install the npm dev packages: |
| 55 | |
| 56 | ```bash |
| 57 | npm install |
| 58 | ``` |
| 59 | |
| 60 | 5. Build the site locally: (Optional) |
| 61 | |
| 62 | ```bash |
| 63 | bundle exec jekyll build |
| 64 | ``` |
| 65 | |
| 66 | 6. To preview the site locally with live reload: |
| 67 | |
| 68 | ```bash |
| 69 | bundle exec jekyll serve |
| 70 | ``` |
| 71 | |
| 72 | This will start a local server, typically at `http://localhost:4000` |
| 73 | |
| 74 | ## Making Changes |
| 75 | |
| 76 | 1. Create a new branch for your documentation changes: |
| 77 | |
| 78 | ```bash |
| 79 | git checkout -b docs/your-feature-name |
| 80 | ``` |
| 81 | |
| 82 | 2. Make your changes to the documentation files in the `docs` directory. |
| 83 | |
| 84 | 3. Test your changes locally using the serve command mentioned above. |
| 85 | |
| 86 | 4. Verify your markdown file changes using the project's linting tools: |
| 87 | |
| 88 | > **Note** |
| 89 | > We use formatting/linting tools to ensure consistent formatting and quality |
| 90 | > across all markdown files. |
| 91 | |
| 92 | ```bash |
| 93 | cd docs |
| 94 | # Run the linter on all Markdown files in the docs directory |
| 95 | npm run lint-md "*.md" |
| 96 | # Or have the linter attempt to format automatically |
| 97 | npm run format-md "*.md" |
| 98 | ``` |
| 99 | |
| 100 | This will check your Markdown files against our style rules and highlight any |
| 101 | issues that need to be fixed. |
| 102 | |
| 103 | 5. Format HTML, CSS, and JavaScript files using the provided npm scripts: |
| 104 | |
| 105 | ```bash |
| 106 | # Format HTML and CSS files |
| 107 | npm run format-html-css |
| 108 | |
| 109 | # Format JavaScript files |
| 110 | npm run format-js |
| 111 | ``` |
| 112 | |
| 113 | 6. Commit your changes: |
| 114 | |
| 115 | ```bash |
| 116 | git add . |
| 117 | git commit -m "docs: your descriptive commit message" |
| 118 | ``` |
| 119 | |
| 120 | 7. Push your branch to your fork: |
| 121 | |
| 122 | ```bash |
| 123 | git push origin docs/your-feature-name |
| 124 | ``` |
| 125 | |
| 126 | ## Verifying Site Changes in Fork |
| 127 | |
| 128 | For the most accurate verification of your documentation changes, follow these |
| 129 | steps: |
| 130 | |
| 131 | 1. Push your branch to your fork: |
| 132 | |
| 133 | ```bash |
| 134 | git push origin docs/your-feature-name |
| 135 | ``` |
| 136 | |
| 137 | 2. Set up GitHub Pages in your fork by following the |
| 138 | [official GitHub Pages documentation](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch). |
| 139 | Make sure to: |
| 140 | |
| 141 | * Configure the source to deploy from your feature branch |
| 142 | * Set the folder to `/docs` |
| 143 | |
| 144 | 3. Wait for GitHub Pages to build and deploy your site. This may take a few |
| 145 | minutes. You can monitor the progress in the "Actions" tab of your repository. |
| 146 | |
| 147 | 4. Once deployed, you can preview your changes at `https://<YOUR_USERNAME>.github.io/fheroes2/` |
| 148 | |
| 149 | 5. Review your changes in the preview environment to ensure: |
| 150 | |
| 151 | * All links work correctly |
| 152 | * Images are displayed properly |
| 153 | * The layout is consistent with the main site |
| 154 | * No broken references or missing assets |
| 155 | |
| 156 | 6. After verifying everything looks correct in your fork's GitHub Pages, create |
| 157 | a Pull Request (PR) from your fork's branch to the main fheroes2 repository for |
| 158 | final review and deployment. |
| 159 | |
| 160 | ## Common Issues and Solutions |
| 161 | |
| 162 | * If you encounter Ruby version conflicts, make sure you're using a compatible |
| 163 | version. You can use tools like `rbenv` or `rvm` to manage Ruby versions. |
| 164 | * If the site doesn't build, check the Jekyll build logs for specific error |
| 165 | messages. |
| 166 | * If images aren't displaying, ensure they're placed in the correct directory |
| 167 | (`docs/images/`) and referenced correctly in your markdown files. |
| 168 | |
| 169 | ## Additional Resources |
| 170 | |
| 171 | * [Jekyll Documentation](https://jekyllrb.com/docs/) |
| 172 | * [GitHub Pages Documentation](https://docs.github.com/en/pages) |
| 173 | * [GitHub Pages Quickstart Guide](https://docs.github.com/en/pages/quickstart#introduction) |
| 174 | * [Deploying from a branch in GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#choosing-a-publishing-source) |
| 175 | * [Markdown Guide](https://www.markdownguide.org/) |