From b23ce2f7880524de0dadc9721447c6b821a28fa8 Mon Sep 17 00:00:00 2001 From: Telles Nobrega Date: Tue, 11 Dec 2018 10:35:32 -0300 Subject: [PATCH] Fixing duplicate label issue. For projects that have multiple APIs documented simultaneously, if the labels are the equal on more than one version of the API build will fail due to duplicate label. Adding a random number to minimize the chance of duplicate label. Change-Id: Ic8434ce79630637a878fa64307796be0f3efe6d1 --- os_api_ref/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/os_api_ref/__init__.py b/os_api_ref/__init__.py index ab272e1..8d455c7 100644 --- a/os_api_ref/__init__.py +++ b/os_api_ref/__init__.py @@ -12,6 +12,7 @@ from collections import OrderedDict import os +import random import re from docutils import nodes @@ -198,7 +199,8 @@ class RestMethodDirective(rst.Directive): # We need to build a temporary target that we can replace # later in the processing to get the TOC to resolve correctly. - temp_target = "%s-selector" % node['target'] + temp_target = "%s-%d-selector" % (node['target'], + random.randint(1, 1000)) target = nodes.target(ids=[temp_target]) self.state.add_target(temp_target, '', target, lineno) section += node