Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Docusaurus v3 and PowerShell 4.7 #175

Merged
merged 32 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cc9d4c2
Docs: update instructions to match Docusaurus v3
bravo-kernel Jan 31, 2024
acffc2f
Refactor to ES import
bravo-kernel Jan 31, 2024
ddbb7bc
Export default all the things
bravo-kernel Jan 31, 2024
8104aa9
Bump docusaurus to 3.1.1
bravo-kernel Jan 31, 2024
f8fb8c3
Revert import in docs to stay compatible with docusaurus v2
bravo-kernel Jan 31, 2024
fe338ec
Show ES import
bravo-kernel Jan 31, 2024
c058a47
Updated expected test results to match Posh 7.4 CommonParameters
bravo-kernel Jan 31, 2024
e907c92
Bump version to 2.x
bravo-kernel Jan 31, 2024
c23ee1c
Update github actions to node v20 versions
bravo-kernel Jan 31, 2024
94d5e75
Upload v3
bravo-kernel Jan 31, 2024
d809a13
Add github action for powershell version
bravo-kernel Jan 31, 2024
06c0e0c
Do not use custom actions before checkout
bravo-kernel Jan 31, 2024
0ba8d61
Better powershell version message
bravo-kernel Jan 31, 2024
701496b
Add macos-13 to the test matrix
bravo-kernel Jan 31, 2024
225f405
Show powershell version for all jobs
bravo-kernel Jan 31, 2024
18472be
Direct powershell version command
bravo-kernel Jan 31, 2024
4d11d2c
Remove custom action for powershell version
bravo-kernel Jan 31, 2024
79e27fc
Test upload-artifact@v4
bravo-kernel Jan 31, 2024
287c81b
Try id for upload artifact
bravo-kernel Jan 31, 2024
2e574bc
Update remaining download-artifact to v4
bravo-kernel Feb 1, 2024
33d91e0
upload-artifact to v4
bravo-kernel Feb 1, 2024
a917b86
Revert to require to stay compatible with docusaurus v2
bravo-kernel Feb 1, 2024
f4ae45a
Revert remaining ES exports
bravo-kernel Feb 1, 2024
69abc51
Revert major module version:
bravo-kernel Feb 1, 2024
9e1edb6
Bump last download-artifact to @v4
bravo-kernel Feb 1, 2024
7800cb0
Grammar
bravo-kernel Feb 1, 2024
68461ba
Bump docs and mdx parser
bravo-kernel Feb 1, 2024
dd35efd
Npx update packages
bravo-kernel Feb 1, 2024
ce75fb3
Require Powershell 7.4.1 for tests
bravo-kernel Feb 1, 2024
a3e7034
Fix code example and repo links
bravo-kernel Feb 1, 2024
ec7aaf7
Force new CI
bravo-kernel Feb 13, 2024
09a04cf
Revert CI force
bravo-kernel Feb 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/bump-main/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runs:
using: composite
steps:
- name: Checkout Main
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: __main
ref: main
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/psgallery-publisher/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runs:
using: composite
steps:
- name: Download Build Output
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

- name: Publish to PSGallery
shell: pwsh
Expand Down
38 changes: 28 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ jobs:
name: Build Module
runs-on: windows-latest
steps:
- name: Show Powershell Version
shell: pwsh
run: $PSVersionTable.PSVersion

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -46,25 +50,26 @@ jobs:
destination: ${{github.workspace}}/output

- name: Upload artifact Modules
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
id: upload-artifact-modules
with:
name: Modules
path: ${{github.workspace}}/output

- name: Upload artifact PesterTests
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: PesterTests
path: ${{github.workspace}}/Tests

- name: Upload artifact RequiredModules
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: RequiredModules
path: ${{github.workspace}}/Dev/RequiredModules.psd1

- name: Upload artifact PSScriptAnalyzer
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: PSScriptAnalyzer
path: ${{github.workspace}}/PSScriptAnalyzerSettings.psd1
Expand All @@ -75,8 +80,12 @@ jobs:
runs-on: windows-latest
needs: build
steps:
- name: Show Powershell Version
shell: pwsh
run: $PSVersionTable.PSVersion

- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -110,9 +119,14 @@ jobs:
- ubuntu-22.04
- macos-11
- macos-12
- macos-13
steps:
- name: Show Powershell Version
shell: pwsh
run: $PSVersionTable.PSVersion

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

- name: Display structure of downloaded artifacts
run: ls -R
Expand All @@ -130,7 +144,7 @@ jobs:
additionalModulePaths: ${{github.workspace}}/Modules

- name: Upload artifact PesterResults
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: matrix.os == 'windows-2022' # only execute on this OS
with:
name: PesterResults
Expand All @@ -152,8 +166,12 @@ jobs:
if: ${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[release]')}}

steps:
- name: Show Powershell Version
shell: pwsh
run: $PSVersionTable.PSVersion

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -169,7 +187,7 @@ jobs:
useConfigFile: true

- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

- name: Publish to PSGallery
uses: ./.github/actions/psgallery-publisher
Expand Down
2 changes: 2 additions & 0 deletions Tests/Integration/Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Each test has a correlating folder in $env:Temp named after the
test containing all output produced by the test (if any)
#>
#Requires -Version 7.4

param(
[Parameter(Mandatory = $True)][System.IO.FileInfo]$TestFolder
)
Expand Down
18 changes: 17 additions & 1 deletion Tests/Integration/HtmlEncodeLessThanBrackets/Expected.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Dummy module to ensure proper html encoding of platyPS escaped opening '<' an
## SYNTAX

```powershell
Test-HtmlEncodeLessThanBrackets [[-Dummy] <String>] [<CommonParameters>]
Test-HtmlEncodeLessThanBrackets [[-Dummy] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -66,6 +66,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction

\{\{ Fill ProgressAction Description \}\}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
18 changes: 17 additions & 1 deletion Tests/Integration/UnescapeInlineCode/Expected.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Dummy module to ensure proper unescaping of `<angle brackets>` inside inline cod
## SYNTAX

```powershell
Test-UnescapeInlineCode [[-Dummy] <String>] [<CommonParameters>]
Test-UnescapeInlineCode [[-Dummy] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -74,6 +74,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction

\{\{ Fill ProgressAction Description \}\}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
2 changes: 2 additions & 0 deletions Tests/Unit/Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
test containing all output produced by the test (if any)

#>
#Requires -Version 7.4.1

param(
[Parameter(Mandatory = $True)][System.IO.FileInfo]$TestFolder
)
Expand Down
20 changes: 18 additions & 2 deletions website/docs/commands/New-DocusaurusHelp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Generates Get-Help documentation in Docusaurus compatible `.mdx` format.
New-DocusaurusHelp [-Module] <String> [[-DocsFolder] <String>] [[-Sidebar] <String>] [[-Exclude] <Array>]
[[-EditUrl] <String>] [[-MetaDescription] <String>] [[-MetaKeywords] <Array>] [[-PrependMarkdown] <String>]
[[-AppendMarkdown] <String>] [-KeepHeader1] [-HideTitle] [-HideTableOfContents] [-NoPlaceHolderExamples]
[-Monolithic] [-VendorAgnostic] [<CommonParameters>]
[-Monolithic] [-VendorAgnostic] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -352,6 +352,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction

\{\{ Fill ProgressAction Description \}\}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down Expand Up @@ -383,4 +399,4 @@ $tempFolder = Get-Item (Join-Path -Path ([System.IO.Path]::GetTempPath()) -Child

## ADDITIONAL INFORMATION

This page was auto-generated using the comment based help in Alt3.Docusaurus.Powershell 1.0.32.
This page was auto-generated using the comment based help in Alt3.Docusaurus.Powershell 1.0.35.
2 changes: 1 addition & 1 deletion website/docs/commands/docusaurus.sidebar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Import this file in your Docusaurus `sidebars.js` file.
*
* Auto-generated by Alt3.Docusaurus.Powershell 1.0.32.
* Auto-generated by Alt3.Docusaurus.Powershell 1.0.35.
*
* Copyright (c) 2019-present, ALT3 B.V.
*
Expand Down
8 changes: 4 additions & 4 deletions website/docs/faq/multi-line-examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ and where it ends.

Code fencing ensures identical rendering across all PowerShell versions and looks similar to:

```
````
.EXAMPLE
```ps
$description = 'Code Fenced example with a description'
Expand All @@ -44,7 +44,7 @@ Code fencing ensures identical rendering across all PowerShell versions and look

- is treated as markdown
- could also contain fenced code blocks itself
```
````

**Please note** that you may use any of the following commonly used opening fences:

Expand All @@ -54,8 +54,8 @@ Code fencing ensures identical rendering across all PowerShell versions and look
- \`\`\`powershell

> For a full list of usage examples see
> [this test module](https://github.com/alt3/Docusaurus.Powershell/blob/main/Tests/Integration/CrossVersionCodeExamples.psm1)
> and [the markdown](https://github.com/alt3/Docusaurus.Powershell/blob/main/Tests/Integration/CrossVersionCodeExamples.expected.mdx)
> [this test module](https://github.com/alt3/Docusaurus.Powershell/blob/main/Tests/Integration/CrossVersionCodeExamples/CrossVersionCodeExamples.psm1)
> and [the markdown](https://github.com/alt3/Docusaurus.Powershell/blob/main/Tests/Integration/CrossVersionCodeExamples/Expected.mdx)
> it renders.

## PowerShell 7 Native Multi-Lines
Expand Down
10 changes: 10 additions & 0 deletions website/docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ title: Installation

## Installation

Open a PowerShell Core

Install the required PowerShell modules once:

```powershell
Install-Module Alt3.Docusaurus.Powershell -Scope CurrentUser
Install-Module PlatyPS -Scope CurrentUser
```

Install the Docusaurus website once:

```powershell
npx create-docusaurus@latest docusaurus classic
```
68 changes: 34 additions & 34 deletions website/docs/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,9 @@ id: usage
title: Usage
---

Adding Docusaurus to a PowerShell Module project requires three steps:
Adding auto-generated Get-Help pages to to your Docusaurus website only requires two steps:

1. Adding the Docusaurus website skeleton
2. Generating Module documentation
3. Starting the Website

## Adding Docusaurus

Open a PowerShell (Core).

Cd into your project's root folder.

Add the Docusaurus website skeleton by running:

```powershell
npx @docusaurus/init@next init docusaurus classic
```

Modify newly created file `docusaurus/sidebars.js` so it looks like this:

```js
const commands = require('./docs/commands/docusaurus.sidebar.js');

module.exports = {
docs: {
Docusaurus: ['doc1', 'doc2', 'doc3'],
Features: ['mdx'],
"Command Reference": commands
},
};
```

## Generating Module Documentation
## Generate PowerShell Module Documentation

To generate Get-Help pages for any PowerShell module run the following command.

Expand All @@ -48,10 +18,40 @@ New-DocusaurusHelp -Module "YourModuleName"
After the command has completed, the `docusaurus/docs/commands` folder
should contain one `.mdx` file for each command exported by the PowerShell module.

## Starting the Website
## Start the Website

To start your website, cd into the `docusaurus` folder and run:

```powershell
yarn start
npm start
```

## Sidebar layout

By default, Docusaurus will automatically generate a sidebar from the docs folder structure.

If you want to change the layout of the sidebar, update `docusaurus/sidebar.js` so it looks like this:

```js
const commands = require('./docs/commands/docusaurus.sidebar.js');

// @ts-check

/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
tutorialSidebar: [
'intro',
{
type: 'category',
label: 'Command Reference',
items: [
commands
],
},
],
};

export default sidebars;
```

For more information about configuring the sidebar please visit https://docusaurus.io/docs/sidebar.
Loading
Loading