Skip to content
Snippets Groups Projects
Commit b7df75cc authored by Benoit Lavenier's avatar Benoit Lavenier Committed by Hugo Trentesaux
Browse files

Generate runtime-error.po

parent 6dec13d1
No related branches found
No related tags found
1 merge request!269Resolve "Generate runtime-error.po"
......@@ -15,9 +15,11 @@ Usage: xtask <COMMAND>
Commands:
build Build duniter binary
gen-calls-doc Generate calls documentation
gen-doc Generate documentation (calls and events)
inject-runtime-code Inject runtime code in raw specs
release-runtime Release a new runtime
update-raw-specs Update raw specs locally with the files published on a Release
create-asset-link Create asset in a release
test Execute unit tests and integration tests End2tests are skipped
help Print this message or the help of the given subcommand(s)
......
{% for pallet in pallets -%}
{% for error in pallet.errors -%}
msgid "{{ pallet.name }}.{{ error.name }}"
msgstr "{{ error.documentation }}"
{% endfor -%}
{% endfor -%}
......@@ -43,6 +43,7 @@ where
const CALLS_DOC_FILEPATH: &str = "docs/api/runtime-calls.md";
const EVENTS_DOC_FILEPATH: &str = "docs/api/runtime-events.md";
const ERRORS_DOC_FILEPATH: &str = "docs/api/runtime-errors.md";
const ERRORS_PO_FILEPATH: &str = "docs/api/runtime-errors.po";
const TEMPLATES_GLOB: &str = "xtask/res/templates/*.md";
const WEIGHT_FILEPATH: &str = "runtime/gdev/src/weights/";
......@@ -306,7 +307,7 @@ pub(super) fn gen_doc() -> Result<()> {
})
});
let (call_doc, event_doc, error_doc) = print_runtime(runtime);
let (call_doc, event_doc, error_doc, error_po) = print_runtime(runtime);
// Generate docs from rust code
Command::new("cargo")
......@@ -348,6 +349,10 @@ pub(super) fn gen_doc() -> Result<()> {
.with_context(|| format!("Failed to create file '{}'", ERRORS_DOC_FILEPATH))?;
file.write_all(error_doc.as_bytes())
.with_context(|| format!("Failed to write to file '{}'", ERRORS_DOC_FILEPATH))?;
let mut file = File::create(ERRORS_PO_FILEPATH)
.with_context(|| format!("Failed to create file '{}'", ERRORS_PO_FILEPATH))?;
file.write_all(error_po.as_bytes())
.with_context(|| format!("Failed to write to file '{}'", ERRORS_PO_FILEPATH))?;
Ok(())
}
......@@ -469,7 +474,7 @@ fn get_weights(max_weight: u128) -> Result<HashMap<String, HashMap<String, Weigh
}
/// use template to render markdown file with runtime calls documentation
fn print_runtime(pallets: RuntimePallets) -> (String, String, String) {
fn print_runtime(pallets: RuntimePallets) -> (String, String, String, String) {
// init variables
let mut user_calls_counter = 0;
let user_calls_pallets: RuntimePallets = pallets
......@@ -568,5 +573,9 @@ fn print_runtime(pallets: RuntimePallets) -> (String, String, String) {
.render("runtime-errors.md", &context)
.expect("template error");
(call_doc, event_doc, error_doc)
let error_po = tera
.render("runtime-errors.po", &context)
.expect("template error");
(call_doc, event_doc, error_doc, error_po)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment