Skip to content

Commit

Permalink
allow/merge duplicate fields
Browse files Browse the repository at this point in the history
  • Loading branch information
graphaelli committed Nov 21, 2018
1 parent 0d89125 commit cbceb4b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions libbeat/scripts/generate_fields_docs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import yaml
import os
import argparse
from collections import OrderedDict
import os

import yaml


def document_fields(output, section, sections, path):
Expand Down Expand Up @@ -102,6 +104,19 @@ def fields_to_asciidoc(input, output, beat):
print("fields.yml file is empty. fields.asciidoc cannot be generated.")
return

# deduplicate fields, last one wins
for section in docs:
fields = OrderedDict()
for field in section["fields"]:
name = field["name"]
if name in fields:
assert field["type"] == fields[name]["type"], 'field "{}" redefined with different type "{}"'.format(
name, field["type"])
fields[name].update(field)
else:
fields[name] = field
section["fields"] = list(fields.values())

# Create sections from available fields
sections = {}
for v in docs:
Expand Down

0 comments on commit cbceb4b

Please sign in to comment.