doc: gen_devicetree_rest: Fix binding doc file name resolution

The `binding_filename` function, which resolves the binding
documentation file name from the binding yaml file name, made a very
crude assumption that the binding yaml file name will always have the
extension name of `yaml` -- this is no longer true after the commit
c453220006, which added support for both
`yaml` or `yml`.

This commit reworks the function such that its implementation is not
dependent on the extension name of the binding yaml file.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2022-07-25 01:04:06 +09:00 committed by Carles Cufí
parent 780ee52bde
commit 99f1911520
1 changed files with 3 additions and 3 deletions

View File

@ -796,9 +796,9 @@ def binding_filename(binding):
if idx == -1:
raise ValueError(f'binding path has no {dts_bindings}: {binding.path}')
# Cut past dts/bindings, strip off the .yaml, and replace with
# .rst.
return as_posix[idx + len(dts_bindings):-4] + 'rst'
# Cut past dts/bindings, strip off the extension (.yaml or .yml), and
# replace with .rst.
return os.path.splitext(as_posix[idx + len(dts_bindings):])[0] + '.rst'
def binding_ref_target(binding):
# Return the sphinx ':ref:' target name for a binding.