github.com/machinebox/remoto@v0.1.2-0.20191024144331-eff21a7d321f/templates/html/docs.bootstrap.html.plush (about)

     1  <% contentFor("describe-field") { %>
     2  	<code><%= underscore(field.Name) %></code>
     3  	<%= if (field.Type.IsMultiple) { %>
     4  	Array of
     5  	<% } %>
     6  	<%= if (field.Type.IsStruct) { %>
     7  		<%= contentOf("structure-link", {"name":field.Type.Name}) %>
     8  	<% } else { %>
     9  		<%= field.Type.Name %>
    10  	<% } %>
    11  	<%= if (field.Comment != "") { %><span class='text-muted'>&mdash;<%= field.Comment %></span><% } %>
    12  <% } %>
    13  <% contentFor("describe-structure") { %>
    14  	<%= contentOf("heading", {"text": structure.Name, "id": id, "tag": "h4", "type": "Object"}) %>
    15  	<p><%= structure.Comment %></p>
    16  	<%= contentOf("describe-fields", {"fields": structure.Fields}) %>
    17  <% } %>
    18  <% contentFor("describe-fields") { %>
    19  	<ul>
    20  	<%= if (len(fields) == 0) { %>
    21  		<li class='text-muted'>
    22  			No fields &mdash;An empty object.
    23  		</li>
    24  	<% } else { %>
    25  		<%= for (field) in fields { %>
    26  			<li>
    27  			<%= contentOf("describe-field", {"field": field}) %>
    28  			</li>
    29  		<% } %>
    30  	<% } %>
    31  	</ul>
    32  <% } %>
    33  <% contentFor("structure-link") { %><a href='#<%= def.PackageName %>_<%= replace(name, ".", "_") %>'><%= name %></a><% } %>
    34  <% contentFor("heading") { %><<%= tag %> class='heading anchor-container'><%= text %> <span class='text-muted'><%= type %></span> <a href='#<%= id %>' class='anchor'>#</a><a href='#top' class='float-right anchor'>top</a></<%= tag %>><% } %>
    35  <!doctype html>
    36  <html>
    37  <head>
    38  	<meta name='generator' content='https://machinebox.com/remoto'>
    39  	<title><%= def.PackageName %> - Docs - Remoto</title>
    40  	<meta name="description" content="<%= def.PackageComment %>" />
    41  	<!-- Twitter Card data -->
    42  	<meta name="twitter:card" content="summary">
    43  	<meta name="twitter:title" content="<%= def.PackageName %> - Docs - Remoto">
    44  	<meta name="twitter:description" content="<%= def.PackageComment %>">
    45  	<meta name="twitter:creator" content="@matryer">
    46  	<!-- Open Graph data -->
    47  	<meta property="og:title" content="<%= def.PackageName %> - Docs - Remoto" />
    48  	<meta property="og:type" content="article" />
    49  	<meta property="og:description" content="<%= def.PackageComment %>" /> 
    50  	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
    51  	<style>
    52  		body {
    53  			padding-top: 50px;
    54  		}
    55  		.content {
    56  			padding: 20px;
    57  		}
    58  		.page {
    59  			padding-top: 10px;
    60  			padding-bottom: 10px;
    61  		}
    62  		.highlightable {
    63  			border-left: 10px white solid;
    64  			transition: border-left 1s;
    65  			padding-left: 10px;
    66  			margin-left: -10px;
    67  		}
    68  		.highlightable.highlight {
    69  			border-left: 10px #f8f9fa solid;
    70  			transition: border-left 1s;
    71  		}
    72  		.anchor-container .anchor {
    73  			opacity: 0;
    74  			color: #ddd;
    75  			font-weight: 200;
    76  		}
    77  		.anchor-container:hover .anchor {
    78  			opacity: 1;
    79  			text-decoration: none;
    80  			transition: color .16s linear;
    81  		}
    82  		.anchor:hover {
    83  			color: #f08da9;
    84  		}
    85  		footer {
    86  			background-color: #f8f9fa;
    87  			padding: 50px;
    88  			font-size: 0.8em;
    89  			text-align: right;
    90  		}
    91  		::selection {
    92  			color: #fff;
    93  			background: #f08da9;
    94  		}
    95  		.heading {
    96  			font-weight: 300;
    97  		}
    98  		.heading .text-muted {
    99  			opacity: 0.5;
   100  			font-weight: 100;
   101  		}
   102  		pre.code {
   103  			background-color: #f8f9fa;
   104  			padding: 10px;
   105  			overflow-y: scroll;
   106  			max-height: 600px;
   107  		}
   108  	</style>
   109  </head>
   110  <body id='top'>
   111  	<nav class='navbar fixed-top navbar-light bg-light'>
   112  		<div class='container'>
   113  			<a class="navbar-brand" href="#top"><%= upcase(def.PackageName) %></a>
   114  			<div class='form-inline'>
   115  				<input id='jump-to' list='symbols' type='text' class='form-control' placeholder='Jump to&hellip;'>
   116  			</div>
   117  		</div>
   118  	</nav>
   119  	<div class='page-body container'>
   120  		<div class='content'>
   121  			<%= if (len(def.Services) > 1) { %>
   122  				<ul class='nav justify-content-end'>
   123  				<%= for (service) in def.Services { %>
   124  					<li class='nav=item'>
   125  						<a class='nav-link' href='#<%= def.PackageName %>_<%= service.Name %>'><%= service.Name %></a>
   126  					</li>
   127  				<% } %>
   128  				</ul>
   129  				<hr>
   130  			<% } %>
   131  			<%= for (service) in def.Services { %>
   132  				<section id='<%= def.PackageName %>_<%= service.Name %>'>
   133  					<h2 class='display-4'>
   134  						<%= service.Name %>
   135  					</h2>
   136  					<p class='lead'>
   137  						<%= service.Comment %>
   138  					</p>
   139  					<div class='row'>
   140  						<div class='col col-auto'>
   141  							<strong>Methods</strong>
   142  							<ul class='list-unstyled'>
   143  							<%= for (method) in service.Methods { %>
   144  								<li>
   145  									<a href='#<%= def.PackageName %>_<%= service.Name %>_<%= method.Name %>'><%= method.Name %></a>
   146  								</li>
   147  							<% } %>
   148  							</ul>
   149  						</div>
   150  						<div class='col col-auto'>
   151  							<strong>Objects</strong>
   152  							<ul class='list-unstyled'>
   153  								<%= for (structure) in service.Structures { %>
   154  									<%= if (!structure.IsRequestObject && !structure.IsResponseObject) { %>
   155  									<li>
   156  										<a href='#<%= def.PackageName %>_<%= structure.Name %>'><%= structure.Name %></a>
   157  									</li>
   158  									<% } %>
   159  									<li>
   160  										<a href='#Objects'>All objects</a>
   161  									</li>
   162  								<% } %>
   163  							</ul>
   164  						</div>
   165  						<div class='col col-auto'>
   166  							<strong>More</strong>
   167  							<ul class='list-unstyled'>
   168  								<li>
   169  									<a href='#<%= def.PackageName %>_Special_types'>Special types</a>
   170  								</li>
   171  								<li>&nbsp;</li>
   172  								<li>
   173  									<a href='#<%= def.PackageName %>_Definition'>Definition</a>
   174  								</li>
   175  							</ul>
   176  						</div>
   177  					</div>
   178  					<hr>
   179  					<%= for (method) in service.Methods { %>
   180  						<section class='page highlightable' id='<%= def.PackageName %>_<%= service.Name %>_<%= method.Name %>'>
   181  							<%= contentOf("heading", {"text": method.Name, "id": def.PackageName+"_"+service.Name+"_"+method.Name, "tag": "h4", "type": "Method"}) %>
   182  							<p>
   183  								<%= method.Comment %>
   184  							</p>
   185  							<div class='row'>
   186  								<div class='col'>
   187  									<p>
   188  										<%= contentOf("structure-link", {"name":method.RequestStructure.Name}) %>
   189  									</p>
   190  									<%= contentOf("describe-fields", {"fields": method.RequestStructure.Fields}) %>
   191  								</div>
   192  								<div class='col'>
   193  									<p>
   194  										<%= contentOf("structure-link", {"name":method.ResponseStructure.Name}) %>
   195  									</p>
   196  									<%= if (method.ResponseStructure.Name == "remototypes.FileResponse") { %>
   197  										<ul>
   198  											<li>File</li>
   199  										</ul>
   200  									<% } else { %>
   201  										<%= contentOf("describe-fields", {"fields": method.ResponseStructure.Fields}) %>
   202  									<% } %>
   203  								</div>
   204  							</div>
   205  						</section>
   206  						<hr>
   207  					<% } %>
   208  				</section>
   209  			<% } %>
   210  			<h3 id='Objects' class='display-5'>Objects</h3>
   211  			<p class='lead'>
   212  				This section describes all the objects (structures) that are used in the <strong><%= def.PackageName %></strong> service.
   213  			</p>
   214  			<ul class='list-unstyled'>
   215  			<%= for (structure) in unique_structures(def) { %>
   216  				<li>
   217  					<a href='#<%= def.PackageName %>_<%= structure.Name %>'><%= structure.Name %></a>
   218  				</li>	
   219  			<% } %>
   220  			</ul>
   221  			<%= for (structure) in unique_structures(def) { %>
   222  				<section class='page highlightable' id='<%= def.PackageName %>_<%= structure.Name %>'>
   223  					<%= contentOf("describe-structure", {"structure": structure, "id": def.PackageName+"_"+structure.Name}) %>
   224  				</section>
   225  				<hr>
   226  			<% } %>
   227  			<h2 id='<%= def.PackageName %>_Special_types' class='display-5'>Special types</h2>
   228  			<p class='lead'>
   229  				This section describes specially handled types for situations
   230  				more complex than simple key/value.
   231  			</p>
   232  			<section class='page highlightable' id='<%= def.PackageName %>_remototypes_FileResponse'>
   233  				<%= contentOf("heading", {"text": "remototypes.FileResponse", "id": def.PackageName+"_remototypes_FileResponse", "tag": "h4", "type": "Object"}) %>
   234  				<p>
   235  					<code>remototypes.FileResponse</code> is used by methods that return a single
   236  					file as its result.
   237  				</p>
   238  				<p>
   239  					Client libraries will provide a way to access the returned file.
   240  				</p>
   241  			</section>
   242  			<section class='page highlightable' id='<%= def.PackageName %>_remototypes_File'>
   243  				<%= contentOf("heading", {"text": "remototypes.File", "id": def.PackageName+"_remototypes_File", "tag": "h4", "type": "Object"}) %>
   244  				<p>
   245  					<code>remototypes.File</code> represents a binary file. Client libraries will each have their
   246  					own special way of submitting the files.
   247  				</p>
   248  			</section>
   249  			<h2 id='<%= def.PackageName %>_Definition' class='display-5'>Definition</h2>
   250  			<p class='lead'>
   251  				Here is the <a href='https://github.com/matryer/remoto'>Remoto</a> definition for this service, which is also available to <a href='#' data-action='download-source'>download</a>.
   252  			</p>
   253  <pre class='source code'><code><%= def.Source() %></code></pre>
   254  		</div>
   255  	</div>
   256  	<footer class='footer'>
   257  		<div class='text-muted container'>
   258  			Powered by 
   259  			<a href='https://github.com/matryer/remoto'>Remoto</a>
   260  		</div>
   261  	</footer>
   262  	<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
   263  	<script>
   264  		$(function(){
   265  
   266  			$.fn.hide = function(){
   267  				$(this).addClass('d-none')
   268  			}
   269  			$.fn.show = function(){
   270  				$(this).removeClass('d-none')
   271  			}
   272  
   273  			function checkJumpTo(){
   274  				var val = $(this).val().replace('.','_')
   275  				var hit = null
   276  				var hash = '<%= def.PackageName %>_' + val
   277  				hash = hash.replace('.','_').replace(' ','_')
   278  				try{ hit = $('#'+hash) }catch{}
   279  				if (hit && hit.length > 0) {
   280  					$(this).val('')
   281  					hit.niceScroll()
   282  					location.hash = hash
   283  				}
   284  			}
   285  			$('#jump-to').keyup(debounce(checkJumpTo, 500)).keyup(function(e){
   286  				if (e.keyCode == 10 || e.keyCode == 13) {
   287  					checkJumpTo.apply(this, arguments)
   288  				}
   289  			})
   290  			$('#jump-to').change(function(){
   291  				checkJumpTo.apply(this, arguments)
   292  			})
   293  
   294  			$(window).keypress(function(e){
   295  				if (e.target.tagName != "BODY") { return }
   296  				if (e.key.length > 1) { return }
   297  				e.preventDefault()
   298  				$('#jump-to').val(e.key).focus()
   299  			})
   300  
   301  			// niceScroll gently scrolls the page to this element.
   302  			$.fn.niceScroll = function(noanimate){
   303  				console.info('niceScroll')
   304  				if ($(this).length === 0) { return }
   305  				noanimate = noanimate || false
   306  				var x = $(this).offset().top - $.fn.niceScroll.topMargin
   307  				if (noanimate) {
   308  					return $('html,body').css({ 
   309  						scrollTop: x
   310  					})
   311  				}
   312  				return $('html,body').animate({ 
   313  					scrollTop: x
   314  				}, 'slow')
   315  			}
   316  			$.fn.niceScroll.topMargin = 60
   317  
   318  			function changeRoute(route, noanimate) {
   319  				if (route == "#") { return }
   320  				if (!route) { return }
   321  				$('.page.highlight').removeClass('highlight')
   322  				var target = $(route).addClass('highlight')
   323  				if (location.hash != route) {
   324  					history.pushState(null, null, route)
   325  				}
   326  				target.niceScroll(noanimate)
   327  			}
   328  			$(window).bind('hashchange', function() {
   329  				changeRoute(location.hash)
   330  			})
   331  			var hash = location.hash
   332  			if (hash.length > 0) {
   333  				changeRoute(hash, true)
   334  			}
   335  
   336  			// $.scrollToTop scrolls the page to the top.
   337  			$.scrollToTop = function(){
   338  				$('html,body').animate({ 
   339  					scrollTop: 0
   340  				}, 'slow')
   341  			}
   342  
   343  			$('a[href^="#"]').click(function(e){
   344  				e.preventDefault()
   345  				var $this = $(this)
   346  				changeRoute($this.attr('href'))
   347  			})
   348  
   349  			// from https://davidwalsh.name/javascript-debounce-function
   350  			// Returns a function, that, as long as it continues to be invoked, will not
   351  			// be triggered. The function will be called after it stops being called for
   352  			// N milliseconds. If `immediate` is passed, trigger the function on the
   353  			// leading edge, instead of the trailing.
   354  			function debounce(func, wait, immediate) {
   355  				var timeout
   356  				return function() {
   357  					var context = this, args = arguments;
   358  					var later = function() {
   359  						timeout = null
   360  						if (!immediate) func.apply(context, args)
   361  					};
   362  					var callNow = immediate && !timeout
   363  					clearTimeout(timeout)
   364  					timeout = setTimeout(later, wait)
   365  					if (callNow) func.apply(context, args)
   366  				}
   367  			}
   368  
   369  			$('[data-action="download-source"]').click(function(e){
   370  				e.preventDefault()
   371  				$.download('<%= def.PackageName %>.remoto.go', $('.source.code code').text())
   372  			})
   373  
   374  			$.download = function(filename, text) {
   375  				var element = document.createElement('a');
   376  				element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
   377  				element.setAttribute('download', filename);
   378  				element.style.display = 'none';
   379  				document.body.appendChild(element);
   380  				element.click();
   381  				document.body.removeChild(element);
   382  			}
   383  
   384  		})
   385  	</script>
   386  	<datalist id='symbols'>
   387  		<%= for (service) in def.Services { %>
   388  			<option value='<%= service.Name %>'>
   389  			<%= for (method) in service.Methods { %>
   390  				<option value='<%= service.Name %>.<%= method.Name %>'>
   391  			<% } %>
   392  			<%= for (structure) in unique_structures(def) { %>
   393  				<option value='<%= structure.Name %>'>
   394  			<% } %>
   395  		<% } %>
   396  		<option value='Special types'>
   397  		<option value='Definition'>
   398  	</datalist>
   399  </body>
   400  </html>