Skip to content

Commit

Permalink
Update vitepress and misc doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Hawxy committed Apr 3, 2024
1 parent 0306479 commit 179ac68
Show file tree
Hide file tree
Showing 14 changed files with 3,811 additions and 3,393 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/setup-node@v4
name: Setup node
with:
node-version: 18
node-version: 20
- run: npm install -g cspell
name: Install cSpell
- run: cspell --config ./docs/cSpell.json "docs/**/*.md"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
config: Release
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
node_version: 18.x
node_version: 20.x

jobs:
build-and-test-code:
Expand All @@ -32,7 +32,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}

Expand Down
10 changes: 5 additions & 5 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ const config: UserConfig<DefaultTheme.Config> = {
text: 'Configuration',
collapsed: false,
items: [
{ text: 'Bootstrap with HostBuilder', link: '/configuration/hostbuilder' },
{ text: 'Bootstrapping Marten', link: '/configuration/hostbuilder' },
{ text: 'Configuring Document Storage', link: '/configuration/storeoptions' },
{ text: 'Json Serialization', link: '/configuration/json' },
{ text: 'Resiliency Policies', link: '/configuration/retries' },
{ text: 'Pre-Building Generated Types', link: '/configuration/prebuilding' },
{ text: 'Command Line Tooling', link: '/configuration/cli' },
{ text: 'Development versus Production Usage', link: '/configuration/optimized_artifact_workflow' },
{ text: 'Optimized Development Workflow', link: '/configuration/optimized_artifact_workflow' },
{ text: 'Multi-Tenancy with Database per Tenant', link: '/configuration/multitenancy' },
{ text: 'Environment Checks', link: '/configuration/environment-checks' },
{ text: 'Custom IoC Integration', link: '/configuration/ioc' },
Expand All @@ -108,7 +108,7 @@ const config: UserConfig<DefaultTheme.Config> = {
{ text: 'Storing Documents', link: '/documents/storing' },
{ text: 'Deleting Documents', link: '/documents/deletes' },
{
text: 'Querying Documents', link: '/documents/querying/', collapsed: false, items: [
text: 'Querying Documents', link: '/documents/querying/', collapsed: true, items: [
{ text: 'Loading Documents by Id', link: '/documents/querying/byid' },
{ text: 'Querying Documents with Linq', link: '/documents/querying/linq/' },
{ text: 'Supported Linq Operators', link: '/documents/querying/linq/operators' },
Expand All @@ -130,7 +130,7 @@ const config: UserConfig<DefaultTheme.Config> = {
},

{
text: 'Indexing Documents', link: '/documents/indexing/', collapsed: false, items: [
text: 'Indexing Documents', link: '/documents/indexing/', collapsed: true, items: [
{ text: 'Calculated Indexes', link: '/documents/indexing/computed-indexes' },
{ text: 'Duplicated Fields', link: '/documents/indexing/duplicated-fields' },
{ text: 'Unique Indexes', link: '/documents/indexing/unique' },
Expand Down Expand Up @@ -165,7 +165,7 @@ const config: UserConfig<DefaultTheme.Config> = {
{ text: 'Metadata', link: '/events/metadata' },
{ text: 'Archiving Streams', link: '/events/archiving' },
{
text: 'Projections Overview', link: '/events/projections/', collapsed: false, items: [
text: 'Projections Overview', link: '/events/projections/', collapsed: true, items: [
{
text: 'Aggregate Projections', link: '/events/projections/aggregate-projections', items: [
{ text: 'Live Aggregations', link: '/events/projections/live-aggregates' },
Expand Down
16 changes: 6 additions & 10 deletions docs/configuration/hostbuilder.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# Bootstrapping in .Net Applications
# Bootstrapping Marten

:::tip
The exact formula for bootstrapping .Net applications has changed quite a bit from early .Net Core to the latest `WebApplication` model in .Net 6.0 at the time this page was last updated. Regardless, the `IServiceCollection` abstraction for registering services in an IoC container has remained stable and everything in this page functions against that model.
:::

As briefly shown in the [getting started](/) page, Marten comes with extension methods for the .Net Core standard `IServiceCollection` to quickly add Marten services to any .Net application that is bootstrapped by either the [Generic IHostBuilder abstraction](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host) or the [ASP.Net Core IWebHostBuilder](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) or the [.Net 6 WebApplication](https://docs.microsoft.com/en-us/aspnet/core/migration/50-to-60?view=aspnetcore-6.0&tabs=visual-studio#new-hosting-model) hosting models.

Jumping right into a basic ASP&#46;NET Core application using the out of the box Web API template, you'd have a class called `Startup` that holds most of the configuration for your application including
the IoC service registrations for your application in the `Startup.ConfigureServices()` method. To add Marten to your application, use the `AddMarten()` method as shown below:
As briefly shown in the [getting started](/) page, Marten comes with the `AddMarten()` extension method for the .NET `IServiceCollection` to quickly add Marten to any ASP&#46;NET Core or Worker Service application:

<!-- snippet: sample_StartupConfigureServices -->
<a id='snippet-sample_startupconfigureservices'></a>
Expand All @@ -19,6 +12,9 @@ builder.Services.AddMarten(options =>
// Establish the connection string to your Marten database
options.Connection(builder.Configuration.GetConnectionString("Marten")!);

// Specify that we want to use STJ as our serializer
options.UseSystemTextJsonForSerialization();

// If we're running in development mode, let Marten just take care
// of all necessary schema building and patching behind the scenes
if (builder.Environment.IsDevelopment())
Expand All @@ -27,7 +23,7 @@ builder.Services.AddMarten(options =>
}
});
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/AspNetCoreWithMarten/Program.cs#L14-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_startupconfigureservices' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/AspNetCoreWithMarten/Program.cs#L15-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_startupconfigureservices' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The `AddMarten()` method will add these service registrations to your application:
Expand Down
8 changes: 1 addition & 7 deletions docs/configuration/optimized_artifact_workflow.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Development versus Production Usage

:::tip
Marten V5.0 introduces the new `AddMarten().OptimizeArtifactWorkflow()` option
that helps users utilize Marten "best practices" for database and code generation
artifact creation.
:::
# Optimized Development Workflow

The original point of Marten was to have a persistence option that mostly got out of your way and
let developers just get things done without having to spend a lot of time fiddling with database
Expand Down
12 changes: 6 additions & 6 deletions docs/configuration/prebuilding.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Pre-Building Generated Types

Marten >= v4 extensively uses runtime code generation backed by [Roslyn runtime compilation](https://jeremydmiller.com/2018/06/04/compiling-code-at-runtime-with-lamar-part-1/) for dynamic code.
Marten uses runtime code generation backed by [Roslyn runtime compilation](https://jeremydmiller.com/2018/06/04/compiling-code-at-runtime-with-lamar-part-1/) for dynamic code.
This is both much more powerful than [source generators](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview) in what it allows us to actually do, but can have
significant memory usage and “[cold start](https://en.wikipedia.org/wiki/Cold_start_(computing))” problems (seems to depend on exact configurations, so it’s not a given that you’ll have these issues).
Fear not though, Marten v4 introduced a facility to “generate ahead” the code to greatly optimize the "cold start" and memory usage in production scenarios.
Fear not though, Marten introduced a facility to “generate ahead” the code to greatly optimize the "cold start" and memory usage in production scenarios.

The code generation for document storage, event handling, event projections, and additional document stores can be done
with one of three modes as shown below:
Expand All @@ -21,17 +21,17 @@ using var store = DocumentStore.For(opts =>

// Marten will only use types that are compiled into
// the application assembly ahead of time. This is the
// V4 "pre-built" model
// "pre-built" model
opts.GeneratedCodeMode = TypeLoadMode.Static;

// New for V5. More explanation in the docs:)
// Explained Below :)
opts.GeneratedCodeMode = TypeLoadMode.Auto;
});
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/CoreTests/Examples/CodeGenerationOptions.cs#L16-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_code_generation_modes' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The *Auto* mode is new for Marten V5 to alleviate usability issues for folks who did not find the command line options or pre-registration
The *Auto* mode was added alleviate usability issues for folks who did not find the command line options or pre-registration
of document types to be practical. Using the `Marten.Testing.Documents.User` document from the Marten testing suite
as an example, let's start a new document store with the `Auto` mode:

Expand Down Expand Up @@ -80,7 +80,7 @@ into the actually deployed binaries for the system in production deployments. Of
you will need to delete the generated code.

:::tip
Just like ASP.Net MVC, Marten uses the `IHostEnvironment.ApplicationName` property to determine the main application assembly. If
Just like ASP.NET Core, Marten uses the `IHostEnvironment.ApplicationName` property to determine the main application assembly. If
that value is missing, Marten falls back to the `Assembly.GetEntryAssembly()` value.
:::

Expand Down
2 changes: 1 addition & 1 deletion docs/documents/aspnetcore.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
For a little more context, see the blog post [Efficient Web Services with Marten V4](https://jeremydmiller.com/2021/09/28/efficient-web-services-with-marten-v4/).
:::

In Marten V4, there is a small new addon that adds helpers for ASP.Net Core development, expressly
Marten has a small addon that adds helpers for ASP.Net Core development, expressly
the ability to very efficiently _stream_ the raw JSON of persisted documents straight to an HTTP response
without every having to waste time with deserialization/serialization or even reading the data into a JSON
string in memory.
Expand Down
5 changes: 0 additions & 5 deletions docs/events/multitenancy.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Event Store Multi-Tenancy

::: tip
The V4 version of the async daemon is able to fully support multi-tenanted event store projections
now.
:::

The event store feature in Marten supports an opt-in multi-tenancy model that captures
events by the current tenant. Use this syntax to specify that:

Expand Down
9 changes: 6 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ builder.Services.AddMarten(options =>
// Establish the connection string to your Marten database
options.Connection(builder.Configuration.GetConnectionString("Marten")!);

// Specify that we want to use STJ as our serializer
options.UseSystemTextJsonForSerialization();

// If we're running in development mode, let Marten just take care
// of all necessary schema building and patching behind the scenes
if (builder.Environment.IsDevelopment())
Expand All @@ -41,7 +44,7 @@ builder.Services.AddMarten(options =>
}
});
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/AspNetCoreWithMarten/Program.cs#L14-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_startupconfigureservices' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/AspNetCoreWithMarten/Program.cs#L15-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_startupconfigureservices' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

See [Bootstrapping with HostBuilder](/configuration/hostbuilder) for more information and options about this integration.
Expand All @@ -52,7 +55,7 @@ Use of the `.AddMarten` integration is not mandatory, see [Creating a standalone

## Postgres

The next step is to get access to a PostgreSQL **9.6+** database schema. If you want to let Marten build database schema objects on the fly at development time,
The next step is to get access to a PostgreSQL **12+** database schema. If you want to let Marten build database schema objects on the fly at development time,
make sure that your user account has rights to execute `CREATE TABLE/FUNCTION` statements.

Marten uses the [Npgsql](http://www.npgsql.org) library to access PostgreSQL from .NET, so you'll likely want to read their [documentation on connection string syntax](http://www.npgsql.org/doc/connection-string-parameters.html).
Expand Down Expand Up @@ -118,7 +121,7 @@ app.MapGet("/user/{id:guid}",
return await session.LoadAsync<User>(id, ct);
});
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/AspNetCoreWithMarten/Program.cs#L40-L75' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_userendpoints' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/AspNetCoreWithMarten/Program.cs#L44-L79' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_userendpoints' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

::: tip INFO
Expand Down
Loading

0 comments on commit 179ac68

Please sign in to comment.