Skip to content

Commit

Permalink
Revise docs generation (#6361)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubo committed Dec 13, 2023
1 parent dd88db6 commit 33528df
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 145 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
required: true
default: master

jobs:
jobs:
update-docs:
name: Update docs
runs-on: ubuntu-latest
Expand All @@ -36,10 +36,14 @@ jobs:
- name: Generate docs
run: |
mv d/docs/fundamentals/configuration.md n/docgen/configuration.md
mv d/docs/interacting/json-rpc-ns/eth_subscribe.md n/docgen/eth_subscribe.md
mv d/docs/interacting/json-rpc-ns/eth_unsubscribe.md n/docgen/eth_unsubscribe.md
mv d/docs/monitoring/metrics/metrics.md n/docgen/metrics.md
cd n/docgen && ./DocGen && cd ../..
mv n/docgen/configuration.md d/docs/fundamentals/configuration.md
rm -f d/docs/interacting/json-rpc-ns/*.md
mv n/docgen/eth_subscribe.md d/docs/interacting/json-rpc-ns/eth_subscribe.md
mv n/docgen/eth_unsubscribe.md d/docs/interacting/json-rpc-ns/eth_unsubscribe.md
mv n/docgen/json-rpc-ns/*.md d/docs/interacting/json-rpc-ns
mv n/docgen/metrics.md d/docs/monitoring/metrics/metrics.md
- name: Tag a new version
Expand All @@ -61,5 +65,3 @@ jobs:
git commit -am "Auto-update docs"
git push origin $head_branch
gh pr create -B main -H $head_branch -t "Auto-update docs" -b "Autogenerated docs on `${{ github.event_name }}`" -l docgen
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,66 @@
using Nethermind.Config;
using Nethermind.Int256;

namespace Nethermind.AccountAbstraction
namespace Nethermind.AccountAbstraction;

[ConfigCategory(HiddenFromDocs = true)]
public interface IAccountAbstractionConfig : IConfig
{
public interface IAccountAbstractionConfig : IConfig
{
[ConfigItem(
Description = "Defines whether UserOperations are allowed.",
DefaultValue = "false")]
bool Enabled { get; set; }
[ConfigItem(
Description = "Defines whether UserOperations are allowed.",
DefaultValue = "false")]
bool Enabled { get; set; }

[ConfigItem(
Description = "Max number of priority AccountAbstraction peers.",
DefaultValue = "20")]
int AaPriorityPeersMaxCount { get; set; }
[ConfigItem(
Description = "Max number of priority AccountAbstraction peers.",
DefaultValue = "20")]
int AaPriorityPeersMaxCount { get; set; }

[ConfigItem(
Description = "Defines the maximum number of UserOperations that can be kept in memory by clients",
DefaultValue = "200")]
int UserOperationPoolSize { get; set; }
[ConfigItem(
Description = "Defines the maximum number of UserOperations that can be kept in memory by clients",
DefaultValue = "200")]
int UserOperationPoolSize { get; set; }

[ConfigItem(
Description = "Defines the maximum number of UserOperations that can be kept for each sender",
DefaultValue = "1")]
int MaximumUserOperationPerSender { get; set; }
[ConfigItem(
Description = "Defines the maximum number of UserOperations that can be kept for each sender",
DefaultValue = "1")]
int MaximumUserOperationPerSender { get; set; }

[ConfigItem(
Description =
"Defines the comma separated list of hex string representations of the addresses of the EntryPoint contract to which transactions can be made",
DefaultValue = "")]
string EntryPointContractAddresses { get; set; }
[ConfigItem(
Description =
"Defines the comma separated list of hex string representations of the addresses of the EntryPoint contract to which transactions can be made",
DefaultValue = "")]
string EntryPointContractAddresses { get; set; }

[ConfigItem(
Description = "Defines the minimum gas price for a user operation to be accepted",
DefaultValue = "1")]
UInt256 MinimumGasPrice { get; set; }
[ConfigItem(
Description = "Defines the minimum gas price for a user operation to be accepted",
DefaultValue = "1")]
UInt256 MinimumGasPrice { get; set; }

[ConfigItem(
Description = "Defines a comma separated list of the hex string representations of paymasters that are whitelisted by the node",
DefaultValue = "")]
string WhitelistedPaymasters { get; set; }
[ConfigItem(
Description = "Defines a comma separated list of the hex string representations of paymasters that are whitelisted by the node",
DefaultValue = "")]
string WhitelistedPaymasters { get; set; }

[ConfigItem(
Description = "Defines the string URL for the flashbots bundle reception endpoint",
DefaultValue = "https://relay.flashbots.net/")]
string FlashbotsEndpoint { get; set; }
}
[ConfigItem(
Description = "Defines the string URL for the flashbots bundle reception endpoint",
DefaultValue = "https://relay.flashbots.net/")]
string FlashbotsEndpoint { get; set; }
}

public static class AccountAbstractionConfigExtensions
{
public static IEnumerable<string> GetEntryPointAddresses(this IAccountAbstractionConfig accountAbstractionConfig) =>
accountAbstractionConfig.EntryPointContractAddresses
.Split(",")
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => s.Trim())
.Distinct();
public static class AccountAbstractionConfigExtensions
{
public static IEnumerable<string> GetEntryPointAddresses(this IAccountAbstractionConfig accountAbstractionConfig) =>
accountAbstractionConfig.EntryPointContractAddresses
.Split(",")
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => s.Trim())
.Distinct();

public static IEnumerable<string> GetWhitelistedPaymasters(this IAccountAbstractionConfig accountAbstractionConfig) =>
accountAbstractionConfig.WhitelistedPaymasters
.Split(",")
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => s.Trim())
.Distinct();
}
public static IEnumerable<string> GetWhitelistedPaymasters(this IAccountAbstractionConfig accountAbstractionConfig) =>
accountAbstractionConfig.WhitelistedPaymasters
.Split(",")
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => s.Trim())
.Distinct();
}
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Api/Extensions/IPluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Nethermind.Api.Extensions;

[ConfigCategory(DisabledForCli = false, HiddenFromDocs = true)]
public interface IPluginConfig : IConfig
{
[ConfigItem(Description = "Order of plugin initialization", DefaultValue = "[Clique, Aura, Ethash, Optimism, AuRaMerge, Merge, MEV, HealthChecks, Hive]")]
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Config/IBlocksConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public interface IBlocksConfig : IConfig
//bool Enabled { get; set; }

[ConfigItem(
Description = "The block gas limit that the block producer should try to reach in the fastest possible way based on the protocol rules. If not specified, then the miner should follow other miners.",
Description = "The block gas limit that the block producer should try to reach in the fastest possible way based on the protocol rules. If not specified, then the block producer should follow others.",
DefaultValue = "null")]
long? TargetBlockGasLimit { get; set; }

[ConfigItem(
Description = "The minimum gas premium (price if before the London hard fork) for transactions accepted by the block producer.",
Description = "The minimum gas premium (or the gas price before the London hard fork) for transactions accepted by the block producer.",
DefaultValue = "1")]
UInt256 MinGasPrice { get; set; }

Expand All @@ -31,7 +31,7 @@ public interface IBlocksConfig : IConfig
[ConfigItem(Description = "The block header extra data up to 32 bytes in length.", DefaultValue = "Nethermind")]
string ExtraData { get; set; }

[ConfigItem(Description = "Seconds per slot.", DefaultValue = "12")]
[ConfigItem(Description = "The block time slot, in seconds.", DefaultValue = "12")]
ulong SecondsPerSlot { get; set; }

byte[] GetExtraDataBytes();
Expand Down
64 changes: 32 additions & 32 deletions src/Nethermind/Nethermind.Config/INoCategoryConfig.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

namespace Nethermind.Config
namespace Nethermind.Config;

[ConfigCategory(HiddenFromDocs = true)]
public interface INoCategoryConfig : IConfig
{
public interface INoCategoryConfig : IConfig
{
[ConfigItem(Description = "Parent directory or path for BaseDbPath, KeyStoreDirectory, LogDirectory configurations.")]
public string DataDir { get; set; }
[ConfigItem(Description = "Parent directory or path for BaseDbPath, KeyStoreDirectory, LogDirectory configurations.")]
public string DataDir { get; set; }

[ConfigItem(Description = "Path to the JSON configuration file.")]
public string Config { get; set; }
[ConfigItem(Description = "Path to the JSON configuration file.")]
public string Config { get; set; }

[ConfigItem(Description = "Path or directory for configuration files.", DefaultValue = "configs")]
public string ConfigsDirectory { get; set; }
[ConfigItem(Description = "Path or directory for configuration files.", DefaultValue = "configs")]
public string ConfigsDirectory { get; set; }

[ConfigItem(Description = "Path or directory for database files.", DefaultValue = "db")]
public string BaseDbPath { get; set; }
[ConfigItem(Description = "Path or directory for database files.", DefaultValue = "db")]
public string BaseDbPath { get; set; }

[ConfigItem(Description = "Log level override. Possible values: OFF|TRACE|DEBUG|INFO|WARN|ERROR")]
public string Log { get; set; }
[ConfigItem(Description = "Log level override. Possible values: OFF|TRACE|DEBUG|INFO|WARN|ERROR")]
public string Log { get; set; }

[ConfigItem(Description = "Path to the NLog config file")]
public string LoggerConfigSource { get; set; }
[ConfigItem(Description = "Path to the NLog config file")]
public string LoggerConfigSource { get; set; }

[ConfigItem(Description = "Plugins directory")]
public string PluginsDirectory { get; set; }
[ConfigItem(Description = "Plugins directory")]
public string PluginsDirectory { get; set; }

[ConfigItem(Description = "Sets the job name for metrics monitoring.", EnvironmentVariable = "NETHERMIND_MONITORING_JOB")]
public string MonitoringJob { get; set; }
[ConfigItem(Description = "Sets the job name for metrics monitoring.", EnvironmentVariable = "NETHERMIND_MONITORING_JOB")]
public string MonitoringJob { get; set; }

[ConfigItem(Description = "Sets the default group name for metrics monitoring.", EnvironmentVariable = "NETHERMIND_MONITORING_GROUP")]
public string MonitoringGroup { get; set; }
[ConfigItem(Description = "Sets the default group name for metrics monitoring.", EnvironmentVariable = "NETHERMIND_MONITORING_GROUP")]
public string MonitoringGroup { get; set; }

[ConfigItem(Description = "Sets the external IP for the node.", EnvironmentVariable = "NETHERMIND_ENODE_IPADDRESS")]
public string EnodeIpAddress { get; set; }
[ConfigItem(Description = "Sets the external IP for the node.", EnvironmentVariable = "NETHERMIND_ENODE_IPADDRESS")]
public string EnodeIpAddress { get; set; }

[ConfigItem(Description = "Enables Hive plugin used for executing Hive Ethereum Tests.", EnvironmentVariable = "NETHERMIND_HIVE_ENABLED", DefaultValue = "false")]
public bool HiveEnabled { get; set; }
[ConfigItem(Description = "Enables Hive plugin used for executing Hive Ethereum Tests.", EnvironmentVariable = "NETHERMIND_HIVE_ENABLED", DefaultValue = "false")]
public bool HiveEnabled { get; set; }

[ConfigItem(Description = "Defines default URL for JSON RPC.", EnvironmentVariable = "NETHERMIND_URL")]
public string Url { get; set; }
[ConfigItem(Description = "Defines default URL for JSON RPC.", EnvironmentVariable = "NETHERMIND_URL")]
public string Url { get; set; }

[ConfigItem(Description = "Defines CORS origins for JSON RPC.", DefaultValue = "*", EnvironmentVariable = "NETHERMIND_CORS_ORIGINS")]
public string CorsOrigins { get; set; }
[ConfigItem(Description = "Defines CORS origins for JSON RPC.", DefaultValue = "*", EnvironmentVariable = "NETHERMIND_CORS_ORIGINS")]
public string CorsOrigins { get; set; }

[ConfigItem(Description = "Defines host value for CLI function \"switchLocal\".", DefaultValue = "http://localhost", EnvironmentVariable = "NETHERMIND_CLI_SWITCH_LOCAL")]
public string CliSwitchLocal { get; set; }
}
[ConfigItem(Description = "Defines host value for CLI function \"switchLocal\".", DefaultValue = "http://localhost", EnvironmentVariable = "NETHERMIND_CLI_SWITCH_LOCAL")]
public string CliSwitchLocal { get; set; }
}
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.JsonRpc/IJsonRpcConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public interface IJsonRpcConfig : IConfig
Description = """
An array of JSON-RPC namespaces to enable. For instance, `[debug,eth]`.
Built-in modules:
Built-in namespaces:
- `admin`
- `client`
Expand Down
9 changes: 5 additions & 4 deletions src/Nethermind/Nethermind.Merge.Plugin/IMergeConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@ public interface IMergeConfig : IConfig
[ConfigItem(Description = "The garbage collection (GC) mode between Engine API calls.", DefaultValue = "Gen1")]
public GcLevel SweepMemory { get; set; }

[ConfigItem(Description = "The memory compaction mode. When set to `Full`, compacts the large object heap (LOH) if `--Merge.SweepMemory` is set to `Gen2`.", DefaultValue = "Yes")]
[ConfigItem(Description = "The memory compaction mode. When set to `Full`, compacts the large object heap (LOH) if `SweepMemory` is set to `Gen2`.", DefaultValue = "Yes")]
public GcCompaction CompactMemory { get; set; }

[ConfigItem(Description = """
Request the garbage collector (GC) to release process memory back to the OS.
Request the garbage collector (GC) to release the process memory.
Allowed values:
- `-1` to disable
- `0` to release every time
- A positive number to realise memory after that many Engine API calls
- A positive number to release memory after that many Engine API calls
""", DefaultValue = "75")]
public int CollectionsPerDecommit { get; set; }

[ConfigItem(Description = "The timeout, in seconds, for the `engine_newPayload*` methods.", DefaultValue = "7", HiddenFromDocs = true)]
[ConfigItem(Description = "The timeout, in seconds, for the `engine_newPayload` method.", DefaultValue = "7", HiddenFromDocs = true)]
public int NewPayloadTimeout { get; }
}
72 changes: 36 additions & 36 deletions src/Nethermind/Nethermind.Mev/IMevConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@
using Nethermind.Core;
using Nethermind.Int256;

namespace Nethermind.Mev
namespace Nethermind.Mev;

[ConfigCategory(HiddenFromDocs = true)]
public interface IMevConfig : IConfig
{
[ConfigItem(
Description = "Defines whether the MEV bundles are allowed.",
DefaultValue = "false")]
bool Enabled { get; set; }

[ConfigItem(
Description = "Defines how long MEV bundles will be kept in memory by clients",
DefaultValue = "3600")]
UInt256 BundleHorizon { get; set; }

[ConfigItem(
Description = "Defines the maximum number of MEV bundles that can be kept in memory by clients",
DefaultValue = "200")]
int BundlePoolSize { get; set; }

[ConfigItem(Description = "Defines the maximum number of MEV bundles to be included within a single block", DefaultValue = "1")]
int MaxMergedBundles { get; set; }

[ConfigItem(Description = "Defines the list of trusted relay addresses to receive megabundles from as a comma separated string",
DefaultValue = "")]
string TrustedRelays { get; set; }
}

public static class MevConfigExtensions
{
public interface IMevConfig : IConfig
{
[ConfigItem(
Description = "Defines whether the MEV bundles are allowed.",
DefaultValue = "false")]
bool Enabled { get; set; }

[ConfigItem(
Description = "Defines how long MEV bundles will be kept in memory by clients",
DefaultValue = "3600")]
UInt256 BundleHorizon { get; set; }

[ConfigItem(
Description = "Defines the maximum number of MEV bundles that can be kept in memory by clients",
DefaultValue = "200")]
int BundlePoolSize { get; set; }

[ConfigItem(Description = "Defines the maximum number of MEV bundles to be included within a single block", DefaultValue = "1")]
int MaxMergedBundles { get; set; }

[ConfigItem(Description = "Defines the list of trusted relay addresses to receive megabundles from as a comma separated string",
DefaultValue = "")]
string TrustedRelays { get; set; }
}

public static class MevConfigExtensions
{
public static IEnumerable<Address> GetTrustedRelayAddresses(this IMevConfig mevConfig) =>
mevConfig.TrustedRelays
.Split(",")
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => s.Trim())
.Distinct()
.Select(s => new Address(s));
}
public static IEnumerable<Address> GetTrustedRelayAddresses(this IMevConfig mevConfig) =>
mevConfig.TrustedRelays
.Split(",")
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => s.Trim())
.Distinct()
.Select(s => new Address(s));
}
6 changes: 3 additions & 3 deletions tools/docgen/ConfigGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ internal static void Generate()
var startMark = "<!--[start autogen]-->";
var endMark = "<!--[end autogen]-->";
var fileName = "configuration.md";
var excluded = new[] { "AccountAbstraction", "Mev", "Plugin" };
var excluded = Enumerable.Empty<string>();

var types = Directory
.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "Nethermind.*.dll")
.SelectMany(a => Assembly.LoadFile(a).GetExportedTypes())
.SelectMany(a => Assembly.LoadFrom(a).GetExportedTypes())
.Where(t => t.IsInterface && typeof(IConfig).IsAssignableFrom(t) &&
!excluded.Any(x => t.FullName?.Contains(x, StringComparison.Ordinal) ?? false))
.OrderBy(t => t.Name);

File.Delete($"~{fileName}");

using var readStream = new StreamReader(File.OpenRead(fileName));
Expand Down
Loading

0 comments on commit 33528df

Please sign in to comment.