Repository structure#
Process-PSModule expects repositories to follow the staged layout produced by Template-PSModule. The workflow inspects this structure to decide what to compile, document, and publish.
<ModuleName>/
├── .github/ # Workflow config, doc/site templates, automation policy
│ ├── linters/ # Rule sets applied by shared lint steps
│ │ ├── .markdown-lint.yml # Markdown rules enforced via super-linter
│ │ ├── .powershell-psscriptanalyzer.psd1 # Analyzer profile for test jobs
│ │ └── .textlintrc # Text lint rules surfaced in Build Docs summaries
│ ├── workflows/ # Entry points for the reusable workflow
│ │ └── Process-PSModule.yml # Consumer hook into this workflow bundle
│ ├── CODEOWNERS # Default reviewers enforced by Process-PSModule checks
│ ├── dependabot.yml # Dependency update cadence handled by GitHub
│ ├── mkdocs.yml # MkDocs config consumed during site builds
│ ├── PSModule.yml # Settings parsed to drive matrices
│ └── release.yml # Release automation template invoked on publish
├── examples/ # Samples referenced in generated documentation
│ └── General.ps1 # Example script ingested by Document-PSModule
├── icon/ # Icon assets linked from manifest and documentation
│ └── icon.png # Default module icon (PNG format)
├── src/ # Module source, see "Module source code structure" below
├── tests/ # Pester suites executed during validation
│ ├── AfterAll.ps1 (optional) # Cleanup script for ModuleLocal runs
│ ├── BeforeAll.ps1 (optional) # Setup script for ModuleLocal runs
│ └── <ModuleName>.Tests.ps1 # Primary test entry point
├── .gitattributes # Normalizes line endings across platforms
├── .gitignore # Excludes build artifacts from source control
├── LICENSE # License text surfaced in manifest metadata
└── README.md # Repository overview rendered on GitHub and docs landing
Key expectations:
- Keep at least one exported function under
src/functions/public/and corresponding tests intests/. - Optional folders (
assemblies,formats,types,variables, and others) are processed automatically when present. - Markdown files in
src/functions/publicsubfolders become documentation pages alongside generated help. - A group's overview page (
<Category>/<Category>.mdnamed after the folder, or<Category>/index.md) becomes that group's section landing page in the docs navigation. - The build step compiles
src/into a root module file and removes the original project layout from the artifact. - Documentation generation mirrors the
src/functions/publichierarchy so help content always aligns with source.
Module source code structure#
How the module is built.
├── src/ # Module source compiled and documented by the pipeline
│ ├── assemblies/ # Bundled binaries copied into the build artifact
│ ├── classes/ # Class scripts merged into the root module
│ │ ├── private/ # Internal classes kept out of exports
│ │ │ └── SecretWriter.ps1 # Example internal class implementation
│ │ └── public/ # Public classes exported via type accelerators
│ │ └── Book.ps1 # Example public class documented for consumers
│ ├── data/ # Configuration loaded into `$script:` scope at runtime
│ │ ├── Config.psd1 # Example config surfaced in generated help
│ │ └── Settings.psd1 # Additional configuration consumed on import
│ ├── formats/ # Formatting metadata registered during build
│ │ ├── CultureInfo.Format.ps1xml # Example format included in manifest
│ │ └── Mygciview.Format.ps1xml # Additional format loaded at import
│ ├── functions/ # Function scripts exported by the module
│ │ ├── private/ # Helper functions scoped to the module
│ │ │ ├── Get-InternalPSModule.ps1 # Sample internal helper
│ │ │ └── Set-InternalPSModule.ps1 # Sample internal helper
│ │ └── public/ # Public commands documented and tested
│ │ ├── Category/ # Optional: organize commands into categories
│ │ │ ├── Get-CategoryCommand.ps1 # Command file within category
│ │ │ └── Category.md # Group overview -> section landing page (or index.md)
│ │ ├── Get-PSModuleTest.ps1 # Example command captured by Microsoft.PowerShell.PlatyPS
│ │ ├── New-PSModuleTest.ps1 # Example command exported and tested
│ │ ├── Set-PSModuleTest.ps1 # Example command exported and tested
│ │ └── Test-PSModuleTest.ps1 # Example command exported and tested
│ ├── init/ # Initialization scripts executed during module load
│ │ └── initializer.ps1 # Example init script included in build output
│ ├── modules/ # Nested modules packaged with the compiled output
│ │ └── OtherPSModule.psm1 # Example nested module staged for export
│ ├── scripts/ # Scripts listed in 'ScriptsToProcess'
│ │ └── loader.ps1 # Loader executed when the module imports
│ ├── types/ # Type data merged into the manifest
│ │ ├── DirectoryInfo.Types.ps1xml # Type definition registered on import
│ │ └── FileInfo.Types.ps1xml # Type definition registered on import
│ ├── variables/ # Variable scripts exported by the module
│ │ ├── private/ # Internal variables scoped to the module
│ │ │ └── PrivateVariables.ps1 # Example private variable seed
│ │ └── public/ # Public variables exported and documented
│ │ ├── Moons.ps1 # Example variable surfaced in generated docs
│ │ ├── Planets.ps1 # Example variable surfaced in generated docs
│ │ └── SolarSystems.ps1 # Example variable surfaced in generated docs
│ ├── finally.ps1 # Cleanup script appended to the root module
│ ├── header.ps1 # Optional header injected at the top of the module
│ ├── manifest.psd1 (optional) # Source manifest reused when present
│ └── README.md # Module-level docs ingested by Document-PSModule
Declaring module dependencies#
Declare module dependencies using
#Requires -Modules
statements at the top of function files in src/functions/public/ or src/functions/private/ that require external modules.
Build-PSModule collects every #Requires -Modules declaration across all
source files, de-duplicates the list, and writes it into the RequiredModules field of the compiled manifest
automatically. For the full range of supported syntax variants, see the
about_Requires
documentation.
Important: Adding
RequiredModulestosrc/manifest.psd1is not supported for this purpose. Those entries are silently ignored by the build and will not appear in the compiled manifest. Use#Requires -Modulesin function files instead.