An Issue with automatic code documentation | PHP - documentation

I'm having a CodeIgniter project with lots of modules and codes residing in it.
Now I would like to create documentation for other new co-workers.
For example
/**
* inline tags demonstration
*
* This class generates bars using the main algorithm, which also
* works heavily with {#link foo()} to rule the world. If I want
* to use the characters "{#link" in a docblock, I just use "{#}link." If
* I want the characters "{#*}" I use "{#}*}"
*
* #author ahobbit
* #copyright middleearth.org XVII
* #version 1.2.3
*/
class bar
{
// beginning of docblock template area
/**##+
* #access private
* #var string
*/
var $_var1 = 'hello';
var $_var2 = 'my';
var $_var3 = 'name';
var $_var4 = 'is';
var $_var5 = 'Bob';
var $_var6 = 'and';
var $_var7 = 'I';
/**
* Two words
*/
var $_var8 = 'like strings';
/**##-*/
var $publicvar = 'Lookee me!';
}
/**
* Makes chocolate bars
*
* There are two aspects to this class.
* {#inheritdoc } In addition, the foo class
* makes the bars chocolate
*/
class foo extends bar
{
/**
* Check if a Sql row exists. (with two values)
*
* This function will check if a selected sql row exists that contains two
* known values.
*
* #param string $tblname Sql Table Name
* #param string $colname Sql Column Name 1
* #param string $value Sql value 1
* #param string $colname2 Sql Column Name 2
* #param string $value2 Sql value 2
* #return boolean returns true if the sql row does exist
*/
function tableHasRow2D($tblname, $colname, $value, $colname2, $value2) {
$row = sqlQuery("SELECT COUNT(*) AS count FROM $tblname WHERE " . "$colname
LIKE '$value' AND $colname2 LIKE '$value2'");
return $row['count'] ? true : false;
}
}
I had made use of with the following commands
I. PHPdoc
E:\xampp\htdocs\CI_Proj> php phpDocumentor.phar -d application
PHP Warning: count(): Parameter must be an array or an object that implements Countable in phar://E:/xampp/htdocs/CI_Proj/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293
Execute transformation using writer "twig"
Execute transformation using writer "twig"
Execute transformation using writer "twig"
Execute transformation using writer "twig"
Execute transformation using writer "twig"
Execute transformation using writer "Graph"
Unable to find the `dot` command of the GraphViz package. Is GraphViz correctly installed and present in your path? 222.041s
Analyze results and write a report to log
.. 0.004s
II. ApiGen
E:\xampp\htdocs\CI_Proj\vendor\bin>apigen generate src "E:\xampp\htdocs\CI_Proj\application" --destination "E:\xampp\htdocs\CI_Proj\docs-apigen" --debug
Fatal error: Cannot use 'Object' as class name as it is reserved in E:\xampp\htdocs\CI_Proj\vendor\latte\latte\src\Latte\Object.php on line 14
ErrorException: Cannot use 'Object' as class name as it is reserved in E:\xampp\htdocs\CI_Proj\vendor\latte\latte\src\Latte\Object.php:14
Stack trace:
#0 [internal function]: Tracy\Debugger::shutdownHandler()
#1 {main}
Unable to log error: Logging directory is not specified.
Is it be possible to add comments to the modules before or after generation of code?
Since I'm looking to add comments to specific modules in the document itself and optionally that would
automatically inserted to the source code, at the right positions.
How should I need to manage the modules and code inside the project and How would I create a browsable HTML-Documentation?
Any other tool that makes generating the documentation directly from your PHP source code, that would be great in advice

Related

Apollo 3.3.2 kotlin escape from optional values in kmm

i have a kmm project which using apollo graphql version 3.3.2
Everything okay with the previous apollo version but the new version i have to set variables with Optional.presentIfNotNull($variable) like this.
val officeId = QueryTrainingsForUserWhereWhereConditions(
Optional.presentIfNotNull(TrainingColumn.OFFICE_ID),
Optional.presentIfNotNull(SQLOperator.IS_NULL)
)
Before when i use apollo v2 it was like this
val officeId = QueryTrainingsForUserWhereWhereConditions(
TrainingColumn.OFFICE_ID,
SQLOperator.IS_NULL
)
i tried to set
generateOptionalOperationVariables.set(false) and try with true
in gradle file but it didn't work
and when i click the QueryTrainingsForUserWhereWhereConditions
apollo generated the code like this
public data class QueryTrainingsForUserWhereWhereConditions(
/**
* The column that is used for the condition.
*/
public val column: Optional<TrainingColumn?> = Optional.Absent,
/**
* The operator that is used for the condition.
*/
public val `operator`: Optional<SQLOperator?> = Optional.Absent,
/**
* The value that is used for the condition.
*/
public val `value`: Optional<Any?> = Optional.Absent,
/**
* A set of conditions that requires all conditions to match.
*/
public val AND: Optional<List<QueryTrainingsForUserWhereWhereConditions>?> = Optional.Absent,
/**
* A set of conditions that requires at least one condition to match.
*/
public val OR: Optional<List<QueryTrainingsForUserWhereWhereConditions>?> = Optional.Absent,
/**
* Check whether a relation exists. Extra conditions or a minimum amount can be applied.
*/
public val HAS: Optional<QueryTrainingsForUserWhereWhereConditionsRelation?> = Optional.Absent,
)
i couldn't remember what was the generated code before with apollo v2.
it's very hard to use this Optional.presentIfNotNull. method in everywhere and i dont want to use this
Is there any solution to fix my problem or any other way to use Optional.presentIfNotNull to handle optional variables ?
Thanks

How to use coordinates from a sql table as parameter input in Weather URL API SSIS script?

I have created a SSIS-project that retrieves weather information (JSON format) using a Web API in a script task. I've been following this tutorial :Weather data API which works great if you only want to retrieve weather information from a fixed set of coordinates.
My goal now is to use a table where I have stored some coordinates as variable input in the API URL parameters instead of having the coordinates already set in the URL https://api.met.no/weatherapi/locationforecast/2.0/compact.json?lat=55.596&lon=15
So what I have done so for
Created a Script task that gathers the weather information:
#region Help: Introduction to the script task
/* The Script Task allows you to perform virtually any operation that can be accomplished in
* a .Net application within the context of an Integration Services control flow.
*
* Expand the other regions which have "Help" prefixes for examples of specific ways to use
* Integration Services features within this script task. */
#endregion
#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Net;
#endregion
namespace ST_6f60bececd8f4f94afaf758869590918
{
/// <summary>
/// ScriptMain is the entry point class of the script. Do not change the name, attributes,
/// or parent of this class.
/// </summary>
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region Help: Using Integration Services variables and parameters in a script
/* To use a variable in this script, first ensure that the variable has been added to
* either the list contained in the ReadOnlyVariables property or the list contained in
* the ReadWriteVariables property of this script task, according to whether or not your
* code needs to write to the variable. To add the variable, save this script, close this instance of
* Visual Studio, and update the ReadOnlyVariables and
* ReadWriteVariables properties in the Script Transformation Editor window.
* To use a parameter in this script, follow the same steps. Parameters are always read-only.
*
* Example of reading from a variable:
* DateTime startTime = (DateTime) Dts.Variables["System::StartTime"].Value;
*
* Example of writing to a variable:
* Dts.Variables["User::myStringVariable"].Value = "new value";
*
* Example of reading from a package parameter:
* int batchId = (int) Dts.Variables["$Package::batchId"].Value;
*
* Example of reading from a project parameter:
* int batchId = (int) Dts.Variables["$Project::batchId"].Value;
*
* Example of reading from a sensitive project parameter:
* int batchId = (int) Dts.Variables["$Project::batchId"].GetSensitiveValue();
* */
#endregion
#region Help: Firing Integration Services events from a script
/* This script task can fire events for logging purposes.
*
* Example of firing an error event:
* Dts.Events.FireError(18, "Process Values", "Bad value", "", 0);
*
* Example of firing an information event:
* Dts.Events.FireInformation(3, "Process Values", "Processing has started", "", 0, ref fireAgain)
*
* Example of firing a warning event:
* Dts.Events.FireWarning(14, "Process Values", "No values received for input", "", 0);
* */
#endregion
#region Help: Using Integration Services connection managers in a script
/* Some types of connection managers can be used in this script task. See the topic
* "Working with Connection Managers Programatically" for details.
*
* Example of using an ADO.Net connection manager:
* object rawConnection = Dts.Connections["Sales DB"].AcquireConnection(Dts.Transaction);
* SqlConnection myADONETConnection = (SqlConnection)rawConnection;
* //Use the connection in some code here, then release the connection
* Dts.Connections["Sales DB"].ReleaseConnection(rawConnection);
*
* Example of using a File connection manager
* object rawConnection = Dts.Connections["Prices.zip"].AcquireConnection(Dts.Transaction);
* string filePath = (string)rawConnection;
* //Use the connection in some code here, then release the connection
* Dts.Connections["Prices.zip"].ReleaseConnection(rawConnection);
* */
#endregion
/// <summary>
/// This method is called when this script task executes in the control flow.
/// Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
/// To open Help, press F1.
/// </summary>
public void Main()
{
string Longitude = (string)Dts.Variables["User::Longitude"].Value.ToString();
string Latitude = (string)Dts.Variables["User::Latitude"].Value.ToString();
var url = #"https://api.met.no/weatherapi/locationforecast/2.0/compact.json?lat=55.596&lon=15";
System.Net.ServicePointManager.DefaultConnectionLimit = int.MaxValue;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.UseDefaultCredentials = true;
req.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
var syncClient = new WebClient();
syncClient.Headers.Add("user-agent", "acmeweathersite.com support#acmeweathersite.com");
var content = syncClient.DownloadString(url);
string connectionString = "Data Source=localhost;Initial Catalog=Weather;Integrated Security=True;";
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand Storproc =
new SqlCommand(#"INSERT INTO [dbo].[Weather] (JSONData)
select #JSONData", conn);
Storproc.Parameters.AddWithValue("#JSONData", content.ToString());
conn.Open();
Storproc.ExecuteNonQuery();
conn.Close();
}
// TODO: Add your code here
Dts.TaskResult = (int)ScriptResults.Success;
}
#region ScriptResults declaration
/// <summary>
/// This enum provides a convenient shorthand within the scope of this class for setting the
/// result of the script.
///
/// This code was generated automatically.
/// </summary>
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
}
}
Created a SQL table with coordinates:
create table Coordinates(
Municipality nvarchar(50),
Latitide nvarchar(50),
Longitude nvarchar(50)
)
INSERT INTO Coordinates (Municipality, Latitide, Longitude)
VALUES (114, 59.5166667, 17.9),
(115, 59.5833333, 18.2),
(117, 59.5, 18.45)
Added the coordinates table as an SQL task:
Finally I added the two variables in the Script task code:
string Longitude = (string)Dts.Variables["User::Longitude"].Value.ToString();
string Latitude = (string)Dts.Variables["User::Latitude"].Value.ToString();
var url = #"https://api.met.no/weatherapi/locationforecast/2.0/compact.json?lat=Latitude&lon=Longitude";
But when I execute the package the Foreach Loop Container just loops forever, no errors pops up but no data is being stored in the database table either. It feels like I have missed something but no really sure what. Very novice when it comes to variables in SSIS so excuse my lack of knowledge. in my example I am using a SQL Server 2019.
Looks like you are nearly there.
Few things to check:
In your SQL, you are selecting 3 columns, so, the 'index' for these columns would be:
Municipality -> index = 0
Latitide -> index = 1
Longitude -> index = 2
i.e., in the variable mapping, you need to use index 1 and 2 instead of zero for all.
https://learn.microsoft.com/en-us/sql/integration-services/control-flow/foreach-loop-container?view=sql-server-ver15
The first column defined in the enumerator item has the index value 0, the second column 1, and so on.
Your spelling for the columns also seems different (Latitide Vs Latitude). Cross-check this as well. i.e., if you run your sql statement manually are you able to see the data ? What are the column names for the result ?
You can also check the variables in your script task (for debugging purposes) by adding a MessageBox.
E.g.,
string longitude = (string)Dts.Variables["User::Longitude"].Value.ToString();
string latitide = (string)Dts.Variables["User::Latitide"].Value.ToString();
string municipality = (string)Dts.Variables["User::Municipality"].Value.ToString();
MessageBox.Show("longitude:" + longitude + ", latitide:" + latitide + ", municipality: " + municipality);

Can i override path in feature file for a test called from another file [duplicate]

I am trying to follow the examples in the demo:
https://github.com/intuit/karate/tree/master/karate-demo/src/test/java/demo/callfeature
I need to do a call from one feature to another, and pass a reference to update. The reference is for a JSON that is read from a file:
Background:
* url url
* header Authorization = token
* def payload = read('event.json')
* set payload.createdByUser = 'karate'
Scenario: Call another feature with arg
* call read('classpath:common/swap-json-elements.feature') payload
* print payload
Inside my swap-json-elements.feature:
Background:
* set new = payload.old
* set payload.new= payload.old
* set payload.old= new
This is not working. It is clear in the documentation that a shared scope is shared when we 'set' is used, while 'def' will create a new variable, and never update the shared one.
What am I missing ?
If you pass an argument, it is passed by value. When you call with "shared scope" you typically don't need to pass arguments. Because all variables are visible anyway. Try a simpler example, and please watch white-space around the = sign.
main.feature:
Feature:
Background:
* def json = { foo: 'bar' }
* call read('called.feature')
Scenario:
* match json == { foo: 'baz' }
called.feature
Feature:
Scenario:
* set json.foo = 'baz'
* match json == { foo: 'baz' }

Karate - Unable to replace graphql query variables through data driven scenario outline 'examples' [duplicate]

I am not sure why replace is not working.
I have a graphql query:
mutation updateLocation{
updateLocation(input: {
address:"<address>",
id:"<storeID>",
name:"<name>",
workingHours: [
{
closingTime:"<closingTime>",
isClosed:false,
openingTime:"<openingTime>"
}
.......
And in feature file I have this:
Given def query = read ('classpath:graphQL/updateStore.graphql')
* replace query.address = "<address>"
* replace query.regionId = "<regionId>"
* replace query.name = "<name>"
* replace query.closingTime = "<closingTime>"
* replace query.openingTime = "<openingTime>"
* replace query.storeID = storeId
And request { query : '#(query)'}
When method post
Then status 200
Examples:
|address |regionId |name |closingTime |openingTime |
|Adrs1 |286 |st1 |20:00 |10:00 |
The replace works for address, regionid, and name but it does not work for closing time or opening time, these two values stay empty.
Also if I define header in background like this:
Given header Authorization = 'Bearer ' + token
I still have to add this line for each request in the same scenario, or I have been missing something?
Works for me:
* def query = 'closingTime:"<closingTime>"'
* replace query.closingTime = '20:00'
* match query == 'closingTime:"20:00"'
So please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
Note that * replace query.closingTime = closingTime should work. I recommend avoiding confusion by using different names for the Examples columns.

Restart numeration in multiple tables with docx4j

I need to create a .docx file using docx4j with many tables based on a template.
Tables must have rows with automatic numeration.
After copying table from template numeration continues in consecutive tables, like this:
table 1
List item
List item
table 2
List item
List item
How can I restart numeration for every table to obtain this:
table 1
List item
List item
table 2
List item
List item
I found that there exists NumberingDefinitionPart.restart() method that could be helpful but how can I apply it on each table?
Could you give example with java code?
For each table after the first, you need to create/add a list level override to the numbering definitions part, then use that in your numPr (ie in your "list item").
The method you mentioned does this:
/**
* For the given list numId, restart the numbering on the specified
* level at value val. This is done by creating a new list (ie <w:num>)
* which uses the existing w:abstractNum.
* #param numId
* #param ilvl
* #param val
* #return
*/
public long restart(long numId, long ilvl, long val)
throws InvalidOperationException {
// Find the abstractNumId
// (Ensure maps are initialised)
if (em == null ) {
getEmulator();
}
ListNumberingDefinition existingLnd = instanceListDefinitions.get( Long.toString(numId) );
if (existingLnd==null) {
throw new InvalidOperationException("List " + numId + " does not exist");
}
BigInteger abstractNumIdVal = existingLnd.getNumNode().getAbstractNumId().getVal();
// Generate the new <w:num
long newNumId = instanceListDefinitions.size() + 1;
org.docx4j.wml.ObjectFactory factory = Context.getWmlObjectFactory();
Num newNum = factory.createNumberingNum();
newNum.setNumId( BigInteger.valueOf(newNumId) );
AbstractNumId abstractNumId = factory.createNumberingNumAbstractNumId();
abstractNumId.setVal(abstractNumIdVal);
newNum.setAbstractNumId(abstractNumId);
LvlOverride lvlOverride = factory.createNumberingNumLvlOverride();
lvlOverride.setIlvl(BigInteger.valueOf(ilvl));
newNum.getLvlOverride().add(lvlOverride);
StartOverride start = factory.createNumberingNumLvlOverrideStartOverride();
start.setVal(BigInteger.valueOf(val));
lvlOverride.setStartOverride(start);
// Add it to the jaxb object and our hashmap
((Numbering)getJaxbElement()).getNum().add(newNum);
ListNumberingDefinition listDef
= new ListNumberingDefinition(newNum, abstractListDefinitions);
instanceListDefinitions.put(listDef.getListNumberId(), listDef);
// Return the new numId
return newNumId;
}
https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/NumberingRestart.java is an example of using it.
In your numPr element in your w:p "list item":
<w:pPr>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>
</w:pPr>
set level (ilvl) to the level you used in the method; set numid to the value the method returns.
As noted in the sample, after the first paragraph using newNumId, it doesn't matter whether subsequent paragraphs use that or the original numId.