Modify anchor text in member indices - jsdoc2md

I would like to modify the default behavior of the {{>member-index~}} partial so that the the #anchor text used for each item is prepended with a URL. For example, by default I get this list using the {{>member-index~}} partial:
* [.deviceType](#Webex.Application+deviceType) : <code>string</code>
* [.isPrivateDataAvailable](#Webex.Application+isPrivateDataAvailable) : <code>boolean</code>
* [.displayContext](#Webex.Application+displayContext) : <code>string</code>
I would like to have the following, where a URL fragment is added before each #:
* [.deviceType](/docs/something#Webex.Application+deviceType) : <code>string</code>
* [.isPrivateDataAvailable](/docs/something#Webex.Application+isPrivateDataAvailable) : <code>boolean</code>
* [.displayContext](/docs/something#Webex.Application+displayContext) : <code>string</code>
I'm familiar with helper overrides, and have modified the _link() function to do this for {#link} tags, but can't find the code that does this when generating member indices.

Related

remove array component from object

I have some compllex component which contains array
this.SomeComponent.subArray
SomeComponent:model1;
model1 definition:
someString1:string;
someString2:string;
someString3:string;
subArray[]
model2 definition:
someString22:string;
someString23:string;
someString24:string;
Now if I console.log(JSON.stringify(this.SomeComponent.subArray));
I get :
SomeComponent[{"someString22":"one","someString23":"yellow","someString24":"water",},
{"someString22":"two","someString23":"red","someString24":"ground",}
{"someString22":"three","someString23":"green","someString24":"air",}]
Now my task is to delete subArray part which has someString23==red.
So When I console log next time I must get only this
SomeComponent[
{"someString22":"two","someString23":"red","someString24":"ground",}
{"someString22":"three","someString23":"green","someString24":"air",}]
How can I do that?
Use filter method like below :-
this.subArray = subArray.filter((item) => item["someString23"]!==red);

How to update values in a nested json file by Powershell

I want to update some values of below content which i believe a json file. This is the output of azure devops release definition and I need to reuse the content modifying some fields.
I can simply update values like id and name using these lines
$ReleaseDef.Name = $newReleaseName
$ReleaseDef.path = $folderQA
But I dont know how to update array fields like artifact and triggers. I can get values by calling $ReleaseDef.artifacts.sourceid
but can not set any values there , It throws errors like The property 'sourceid' cannot be found on this object. Verify that the
property exists and can be set.
Please suggest
source : userInterface
revision : 4
description :
createdBy : #{displayName=Jyotiprakash Nayak; url=https://azuredevopsdv
.ril.com/EntApps/_apis/Identities/2ca8bd5d-7797-4177-b7bb-2
6daa0d29ed9; _links=;
id=2ca8bd5d-7797-4177-b7bb-26daa0d29ed9;
uniqueName=domain\Jyotiprakash.Nayak; imageUrl=https://azuredev
opsdv.company.com/EntApps/_apis/GraphProfile/MemberAvatars/win.
Uy0xLTUtMjEtMjIwNzU5NTE2Ni03MjEyNTY2NjUtNTU2MTkwNDkyLTQ4NjY
yMw; descriptor=win.Uy0xLTUtMjEtMjIwNzU5NTE2Ni03MjEyNTY2NjU
tNTU2MTkwNDkyLTQ4NjYyMw}
createdOn : 2019-12-10T09:11:11.057Z
modifiedBy : #{displayName=Jyotiprakash Nayak; url=https://azuredevopsdv
.company.com/EntApps/_apis/Identities/2ca8bd5d-7797-4177-b7bb-2
6daa0d29ed9; _links=;
id=2ca8bd5d-7797-4177-b7bb-26daa0d29ed9;
uniqueName=Domain\Jyotiprakash.Nayak; imageUrl=https://azuredev
opsdv.comapny.com/EntApps/_apis/GraphProfile/MemberAvatars/win.
Uy0xLTUtMjEtMjIwNzU5NTE2Ni03MjEyNTY2NjUtNTU2MTkwNDkyLTQ4NjY
yMw; descriptor=win.Uy0xLTUtMjEtMjIwNzU5NTE2Ni03MjEyNTY2NjU
tNTU2MTkwNDkyLTQ4NjYyMw}
modifiedOn : 2019-12-13T09:16:13.463Z
isDeleted : False
variables :
variableGroups : {}
environments : {#{id=7; name=Stage 1; rank=1; owner=; variables=;
variableGroups=System.Object[]; preDeployApprovals=;
deployStep=; postDeployApprovals=;
deployPhases=System.Object[]; environmentOptions=;
demands=System.Object[]; conditions=System.Object[];
executionPolicy=; schedules=System.Object[];
currentRelease=; retentionPolicy=; processParameters=;
properties=; preDeploymentGates=; postDeploymentGates=;
environmentTriggers=System.Object[]; badgeUrl=https://azure
devopsdv.comapny.com/EntApps/_apis/public/Release/badge/e0b1a36
0-01a5-4eea-af57-b2a461559ac9/7/7}}
artifacts : {#{sourceId=e0b1a360-01a5-4eea-af57-b2a461559ac9:48;
type=Build; alias=_eCAM-Team-CI; definitionReference=;
isPrimary=True; isRetained=False}}
triggers : {#{artifactAlias=_eCAM-Team-CI;
triggerConditions=System.Object[];
triggerType=artifactSource}}
releaseNameFormat : Release-$(rev:r)
tags : {}
pipelineProcess : #{type=designer}
properties : #{DefinitionCreationSource=}
id : 7
name : Release-Template-1
path : \QA
projectReference :
url : https://azuredevopsdv.company.com/EntApps/e0b1a360-01a5-4eea-af
57-b2a461559ac9/_apis/Release/definitions/7
_links : #{self=; web=}
These attributes contain hash table values.
You should be able to update by specifying the key and its new value like so:
$ReleaseDef.artifacts["sourceid"] = "someValueHere"
Thanks all for your valuable helps, I finally made it work through some foreach loops.
```$artifact = $json.artifacts
foreach ($value in $artifact)
{
$value.alias = "_$newReleaseName"
$value.sourceId = "$($projectid):$($BuildID)"
}
foreach ($triggervalue in $snapshot.triggers)
{
$triggervalue.artifactAlias = "_$newReleaseName"
}```

How do I paginate a collection or custom query into API json in Laravel?

I have a complex query that is not based on any specific model table that I want to paginate output for. However laravel's built in pagination relies on models and tables. How can I paginate a collection and have the output match up with laravel's built in pagination output format?
I keep this in an app\Core\Helpers class so that I can call them from anywhere as \App\Core\Helpers::makePaginatorForCollection($query_results). The most likely place to use this is the last line of a controller that deals with complex queries.
In app/Http/Controllers/simpleExampleController.php
/**
* simpleExampleController
**/
public function myWeirdData(Request $request){
$my_unsafe_sql = '...';//never do this!!
$result = DB::statement(DB::raw($my_unsafe_sql));
return \App\Core\Helpers::makePaginatorForCollection($result);
}
In app\Core\Helpers.php or anywhere you like that auto loads.
/**
* This will match laravel's built in Model::paginate()
* because it uses the same underlying code.
*
* #param \Illuminate\Support\Collection $collection
*
* #return \Illuminate\Pagination\LengthAwarePaginator
*/
public static function makePaginatorForCollection(\Illuminate\Support\Collection $collection){
$current_page = (request()->has('page')? request()->page : 1) -1;//off by 1 (make zero start)
$per_page = (request()->has('per_page')? request()->per_page : config('api.pagination.per_page')) *1;//make numeric
$page_data = $collection->slice($current_page * $per_page, $per_page)->all();
return new \Illuminate\Pagination\LengthAwarePaginator(array_values($page_data), count($collection), $per_page);
}
/**
* Copy and refactor makePaginatorForCollection()
* if collection building is too slow.
*
* #param $array
*
* #return \Illuminate\Pagination\LengthAwarePaginator
*/
public static function makePaginatorForArray($array){
$collection = collect($array);
return self::makePaginatorForCollection($collection);
}

Is there any standard format for config comment of file with code?

I need to pass some informations to files and parse it later.
WordPress (php) does it like:
<?php
/*
Template Name: My template
*/
?>
However I need to pass a little more complex data like:
/*
* #param name : "Some name" | type : "int" | default : 3 | Description goes here
* #param name : "Another name" | type : "int" | default : 3 | Description goes here
* #param name : "Bla name" | type : "int" | default : 3 | Description goes here
*
*/
Target is it must be readable and easly modified by no-technical people
I was looking for some standard here but I didnt find any. I was checking some function documentation standard like
/**
* Display a variable's contents using nice HTML formatting and will
* properly display the value of booleans as true or false
*
* #see var_dump_plain()
*
* #param mixed $var The variable to dump
* #return string
*/
public static function var_dump( $var, $return = FALSE ) {
//
}
But it's missing some additional fields that I need to be passed to every #param for example (like read name or default value)

how to parse nested json object

I am using json parser lib written in C to parse JSON objects. The lib link is : https://github.com/udp/json-parser.
The json object/string, which I am trying to parse is :
{"video_id": 105, "st": "S3", "processing" : [{"start" : "1", "end" : "2"}]}}
"processing" contains another JSON object.
I have parsed the first three items. But I am not able to figure out a way to parse the "processing" json object. I am using following code:-
if (!strcmp(json->u.object.values[i].name, "video_id"))
{
video_id=json->u.object.values[i].value->u.integer;
}
.
.
if (!strcmp(json->u.object.values[i].name, "processing"))
{
printf("\nNumber of JSON OBJECTS : %d\n", json->u.object.values[i].value->u.object.length);
}
json is the parsed object obtained via calling the lib on the JSON string. Can anyone guide me how to handle the nested object ?
Any help will be really appreciated
My complete code is :
json_value *json;
json_char *json_object="{\"video_id\": 105, \"st\": \"S3\", \"processing\" : [{\"type\" : \"clipping\"},{\"fese\" : \"dipping\"}]}";
printf("%s",json_object);
//json_value * json_parse (const json_char * json,
// size_t length);
json=json_parse(json_object, strlen(json_object));
// json_type json_object;
printf("\n%s\n",json->u.object.values[0].name);
printf("\t%d\n",json->u.object.values[0].value->u.integer);
printf("\n%s\n",json->u.object.values[2].name);
printf("\t%d\n",json->u.object.values[2].value->u.object.length);
printf("\t%s\n",json->u.object.values[2].value->u.object.values[0].name);
From the documentation, API field::
The type field of json_value is one of:
json_object (see u.object.length, u.object.values[x].name, u.object.values[x].value)
json_array (see u.array.length, u.array.values)
json_integer (see u.integer)
json_double (see u.dbl)
json_string (see u.string.ptr, u.string.length)
json_boolean (see u.boolean)
json_null
So, check the type field of the "processing" value. If found to be json_array, do a json_parse for the array to get a new json_value. Now this json_value will provide you with the nested JSON objects.
Take these as reference:
js_v->u.object.values[1].value->u.array.values[0]->type
js_v->u.object.values[1].value->u.array.values[0]->u.string.ptr
I've used them to reference to a string element inside an array:
{"t":"type","d":["element1","element2","element3"]}
In your case, I think you should to repeat the structure like this:
js_v->u.object.values[2].value->u.array.values[0]->u.object.values[0]->u.string.ptr
luck!

Resources