changeset 18526:6f84531b2f16 draft

(svn r23370) -Add: support @api tag in API header files, to select which API should receive the defined classes and functions
author truebrain <truebrain@openttd.org>
date Tue, 29 Nov 2011 23:27:26 +0000
parents 07fcdb4bab4a
children 0f414a707909
files src/ai/api/squirrel_export.awk src/ai/api/squirrel_export.sh src/script/api/script_accounting.hpp src/script/api/script_airport.hpp src/script/api/script_base.hpp src/script/api/script_basestation.hpp src/script/api/script_bridge.hpp src/script/api/script_bridgelist.hpp src/script/api/script_cargo.hpp src/script/api/script_cargolist.hpp src/script/api/script_company.hpp src/script/api/script_controller.hpp src/script/api/script_date.hpp src/script/api/script_depotlist.hpp src/script/api/script_engine.hpp src/script/api/script_enginelist.hpp src/script/api/script_error.hpp src/script/api/script_event.hpp src/script/api/script_event_types.hpp src/script/api/script_execmode.hpp src/script/api/script_gamesettings.hpp src/script/api/script_group.hpp src/script/api/script_grouplist.hpp src/script/api/script_industry.hpp src/script/api/script_industrylist.hpp src/script/api/script_industrytype.hpp src/script/api/script_industrytypelist.hpp src/script/api/script_list.hpp src/script/api/script_log.hpp src/script/api/script_map.hpp src/script/api/script_marine.hpp src/script/api/script_object.hpp src/script/api/script_order.hpp src/script/api/script_rail.hpp src/script/api/script_railtypelist.hpp src/script/api/script_road.hpp src/script/api/script_sign.hpp src/script/api/script_signlist.hpp src/script/api/script_station.hpp src/script/api/script_stationlist.hpp src/script/api/script_subsidy.hpp src/script/api/script_subsidylist.hpp src/script/api/script_testmode.hpp src/script/api/script_tile.hpp src/script/api/script_tilelist.hpp src/script/api/script_town.hpp src/script/api/script_townlist.hpp src/script/api/script_tunnel.hpp src/script/api/script_vehicle.hpp src/script/api/script_vehiclelist.hpp src/script/api/script_waypoint.hpp src/script/api/script_waypointlist.hpp
diffstat 52 files changed, 240 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/api/squirrel_export.awk
+++ b/src/ai/api/squirrel_export.awk
@@ -40,6 +40,39 @@
 	}
 }
 
+function dump_fileheader()
+{
+	# Break the Id tag, so SVN doesn't replace it
+	print "/* $I" "d$ */"
+	print ""
+	print "/*"
+	print " * This file is part of OpenTTD."
+	print " * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2."
+	print " * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+	print " * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>."
+	print " */"
+	print ""
+	print "/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */"
+	print ""
+	print "#include \"../../script/api/" filename "\""
+}
+
+function reset_reader()
+{
+	enum_size = 0
+	enum_value_size = 0
+	enum_string_to_error_size = 0
+	enum_error_to_string_size = 0
+	struct_size = 0
+	method_size = 0
+	static_method_size = 0
+	virtual_class = "false"
+	cls = ""
+	start_squirrel_define_on_next_line = "false"
+	cls_level = 0
+	cls_in_api = ""
+}
+
 BEGIN {
 	enum_size = 0
 	enum_value_size = 0
@@ -52,26 +85,35 @@
 	virtual_class = "false"
 	super_cls = ""
 	cls = ""
+	api_selected = ""
+	cls_in_api = ""
 	start_squirrel_define_on_next_line = "false"
+	has_fileheader = "false"
 	cls_level = 0
 	RS = "\r|\n"
 }
 
 /@file/ {
-	# Break it, so SVN doesn't replace it
-	print "/* $I" "d$ */"
-	print ""
-	print "/*"
-	print " * This file is part of OpenTTD."
-	print " * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2."
-	print " * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-	print " * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>."
-	print " */"
-	print ""
-	print "/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */"
-	print ""
-	gsub("^" tolower(api) "_", "script_", $3)
-	print "#include \"../../script/api/" $3 "\""
+	filename = $3
+	gsub("^" tolower(api) "_", "script_", filename)
+}
+
+/^([	 ]*)\* @api/ {
+	# By default, classes are not selected
+	if (cls_level == 0) api_selected = "false"
+
+	gsub("^([	 ]*)", "", $0)
+	gsub("* @api ", "", $0)
+
+	if ($0 == "none") {
+		api_selected = "false"
+	} else if ($0 == "-all") {
+		api_selected = "false"
+	} else if (match($0, "-" tolower(api))) {
+		api_selected = "false"
+	} else if (match($0, tolower(api))) {
+		api_selected = "true"
+	}
 }
 
 # Remove the old squirrel stuff
@@ -84,10 +126,16 @@
 # We only want to have public functions exported for now
 /^(	*)class/     {
 	if (cls_level == 0) {
+		if (api_selected == "") {
+			print "Class '"$2"' has no @api. It won't be published to any API." > "/dev/stderr"
+			api_selected = "false"
+		}
 		public = "false"
 		cls_param[0] = ""
 		cls_param[1] = 1
 		cls_param[2] = "x"
+		cls_in_api = api_selected
+		api_selected = ""
 		cls = $2
 		if (match($4, "public") || match($4, "protected") || match($4, "private")) {
 			super_cls = $5
@@ -95,8 +143,13 @@
 			super_cls = $4
 		}
 	} else if (cls_level == 1) {
-		struct_size++
-		structs[struct_size] = cls "::" $2
+		if (api_selected == "") api_selected = cls_in_api
+
+		if (api_selected == "true") {
+			struct_size++
+			structs[struct_size] = cls "::" $2
+		}
+		api_selected = ""
 	}
 	cls_level++
 	next
@@ -119,11 +172,6 @@
 }
 { if (doxygen_skip == "true") next }
 
-# Ignore functions that shouldn't be exported to squirrel
-/^#ifndef EXPORT_SKIP/          { export_skip = "true"; next; }
-/^#endif \/\* EXPORT_SKIP \*\// { export_skip = "false"; next; }
-{ if (export_skip == "true") next }
-
 # Ignore the comments
 /^#/             { next; }
 /\/\*.*\*\//     { comment = "false"; next; }
@@ -134,20 +182,42 @@
 # We need to make specialized conversions for structs
 /^(	*)struct/ {
 	cls_level++
+
+	# Check if we want to publish this struct
+	if (api_selected == "") api_selected = cls_in_api
+	if (api_selected == "false") {
+		api_selected = ""
+		next
+	}
+	api_selected = ""
+
 	if (public == "false") next
 	if (cls_level != 1) next
+
 	struct_size++
 	structs[struct_size] = cls "::" $2
+
 	next
 }
 
 # We need to make specialized conversions for enums
 /^(	*)enum/ {
 	cls_level++
-	if (public == "false") next;
+
+	# Check if we want to publish this enum
+	if (api_selected == "") api_selected = cls_in_api
+	if (api_selected == "false") {
+		api_selected = ""
+		next
+	}
+	api_selected = ""
+
+	if (public == "false") next
+
 	in_enum = "true"
 	enum_size++
 	enums[enum_size] = cls "::" $2
+
 	next
 }
 
@@ -168,6 +238,16 @@
 # Empty/white lines. When we may do the Squirrel export, do that export.
 /^([ 	]*)$/ {
 	if (start_squirrel_define_on_next_line == "false") next
+
+	if (cls_in_api != "true") {
+		reset_reader()
+		next
+	}
+	if (has_fileheader == "false") {
+		dump_fileheader()
+		has_fileheader = "true"
+	}
+
 	spaces = "                                                               ";
 	public = "false"
 	namespace_opened = "false"
@@ -310,17 +390,9 @@
 	print "	SQ" api_cls ".PostRegister(engine);"
 	print "}"
 
-	enum_size = 0
-	enum_value_size = 0
-	enum_string_to_error_size = 0
-	enum_error_to_string_size = 0
-	struct_size = 0
-	method_size = 0
-	static_method_size = 0
-	virtual_class = "false"
-	cls = ""
-	start_squirrel_define_on_next_line = "false"
-	cls_level = 0
+	reset_reader()
+
+	next
 }
 
 # Skip non-public functions
@@ -370,7 +442,13 @@
 # Add a method to the list
 /^.*\(.*\).*$/ {
 	if (cls_level != 1) next
-	if (match($0, "~")) next
+	if (match($0, "~")) {
+		if (api_selected != "") {
+			print "Destructor for '"cls"' has @api. Tag ignored." > "/dev/stderr"
+			api_selected = ""
+		}
+		next
+	}
 
 	is_static = match($0, "static")
 	if (match($0, "virtual")) {
@@ -389,6 +467,10 @@
 
 	funcname = $2
 	if ($1 == cls && funcname == "") {
+		if (api_selected != "") {
+			print "Constructor for '"cls"' has @api. Tag ignored." > "/dev/stderr"
+			api_selected = ""
+		}
 		cls_param[0] = param_s
 		if (param_s == "") next
 	} else if (funcname == "") next
@@ -422,6 +504,14 @@
 		}
 	}
 
+	# Check if we want to publish this function
+	if (api_selected == "") api_selected = cls_in_api
+	if (api_selected == "false") {
+		api_selected = ""
+		next
+	}
+	api_selected = ""
+
 	if ($1 == cls && funcname == "") {
 		cls_param[1] = len;
 		cls_param[2] = types;
--- a/src/ai/api/squirrel_export.sh
+++ b/src/ai/api/squirrel_export.sh
@@ -26,13 +26,20 @@
 
 if [ -z "$1" ]; then
 	for f in `ls ../../script/api/*.hpp`; do
-		bf=`basename $f | sed s/script/${apilc}/`
-		case "${bf}" in
-			# these files should not be changed by this script
-			"ai_controller.hpp" | "ai_object.hpp" | "ai_types.hpp" | "ai_changelog.hpp" | "ai_info_docs.hpp" ) continue;
-		esac
+		bf=`basename ${f} | sed s/script/${apilc}/`
+
+		# ScriptController has custom code, and should not be generated
+		if [ "`basename ${f}`" = "script_controller.hpp" ]; then continue; fi
+
 		${AWK} -v api=${apiuc} -f squirrel_export.awk ${f} > ${bf}.tmp
-		if ! [ -f "${bf}.sq" ] || [ -n "`diff -I '$Id' ${bf}.tmp ${bf}.sq 2> /dev/null || echo boo`" ]; then
+
+		if [ "`wc -l ${bf}.tmp | cut -d\  -f1`" = "0" ]; then
+			if [ -f "${bf}.sq" ]; then
+				echo "Deleted: ${bf}.sq"
+				svn del --force ${bf}.sq > /dev/null 2>&1
+			fi
+			rm -f ${bf}.tmp
+		elif ! [ -f "${bf}.sq" ] || [ -n "`diff -I '$Id' ${bf}.tmp ${bf}.sq 2> /dev/null || echo boo`" ]; then
 			mv ${bf}.tmp ${bf}.sq
 			echo "Updated: ${bf}.sq"
 			svn add ${bf}.sq > /dev/null 2>&1
@@ -44,7 +51,13 @@
 	done
 else
 	${AWK} -v api=${apiuc} -f squirrel_export.awk $1 > $1.tmp
-	if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' $1.sq $1.tmp 2> /dev/null || echo boo`" ]; then
+	if [ `wc -l $1.tmp | cut -d\  -f1` -eq "0" ]; then
+		if [ -f "$1.sq" ]; then
+			echo "Deleted: $1.sq"
+			svn del --force $1.sq > /dev/null 2>&1
+		fi
+		rm -f $1.tmp
+	elif ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' $1.sq $1.tmp 2> /dev/null || echo boo`" ]; then
 		mv $1.tmp $1.sq
 		echo "Updated: $1.sq"
 		svn add $1.sq > /dev/null 2>&1
--- a/src/script/api/script_accounting.hpp
+++ b/src/script/api/script_accounting.hpp
@@ -17,6 +17,7 @@
 /**
  * Class that keeps track of the costs, so you can request how much a block of
  *  commands did cost in total. Works in both Execute as in Test mode.
+ * @api ai
  * Example:
  * <pre>
  *   {
--- a/src/script/api/script_airport.hpp
+++ b/src/script/api/script_airport.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all airport related functions.
+ * @api ai
  */
 class ScriptAirport : public ScriptObject {
 public:
--- a/src/script/api/script_base.hpp
+++ b/src/script/api/script_base.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles some basic functions.
+ * @api ai
  *
  * @note The random functions are not called Random and RandomRange, because
  *        RANDOM_DEBUG does some tricky stuff, which messes with those names.
--- a/src/script/api/script_basestation.hpp
+++ b/src/script/api/script_basestation.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Base class for stations and waypoints.
+ * @api ai
  */
 class ScriptBaseStation : public ScriptObject {
 public:
--- a/src/script/api/script_bridge.hpp
+++ b/src/script/api/script_bridge.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all bridge related functions.
+ * @api ai
  */
 class ScriptBridge : public ScriptObject {
 public:
--- a/src/script/api/script_bridgelist.hpp
+++ b/src/script/api/script_bridgelist.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Create a list of bridges.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptBridgeList : public ScriptList {
@@ -25,6 +26,7 @@
 
 /**
  * Create a list of bridges that can be built on a specific length.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptBridgeList_Length : public ScriptList {
--- a/src/script/api/script_cargo.hpp
+++ b/src/script/api/script_cargo.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all cargo related functions.
+ * @api ai
  */
 class ScriptCargo : public ScriptObject {
 public:
--- a/src/script/api/script_cargolist.hpp
+++ b/src/script/api/script_cargolist.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Creates a list of cargos that can be produced in the current game.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptCargoList : public ScriptList {
@@ -27,6 +28,7 @@
  * Creates a list of cargos that the given industry accepts.
  * @note This list also includes cargos that are temporarily not accepted
  *   by this industry, @see ScriptIndustry::IsCargoAccepted.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptCargoList_IndustryAccepting : public ScriptList {
@@ -39,6 +41,7 @@
 
 /**
  * Creates a list of cargos that the given industry can produce.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptCargoList_IndustryProducing : public ScriptList {
@@ -51,6 +54,7 @@
 
 /**
  * Creates a list of cargos that the given station accepts.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptCargoList_StationAccepting : public ScriptList {
--- a/src/script/api/script_company.hpp
+++ b/src/script/api/script_company.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all company related functions.
+ * @api ai
  */
 class ScriptCompany : public ScriptObject {
 public:
--- a/src/script/api/script_controller.hpp
+++ b/src/script/api/script_controller.hpp
@@ -19,6 +19,7 @@
  * The Controller, the class each Script should extend. It creates the Script,
  *  makes sure the logic kicks in correctly, and that GetTick() has a valid
  *  value.
+ * @api ai
  */
 class ScriptController {
 	friend class AIScanner;
--- a/src/script/api/script_date.hpp
+++ b/src/script/api/script_date.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all date related (calculation) functions.
+ * @api ai
  *
  * @note Months and days of month are 1-based; the first month of the
  *       year is 1 and the first day of the month is also 1.
--- a/src/script/api/script_depotlist.hpp
+++ b/src/script/api/script_depotlist.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Creates a list of the locations of the depots (and hangars) of which you are the owner.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptDepotList : public ScriptList {
--- a/src/script/api/script_engine.hpp
+++ b/src/script/api/script_engine.hpp
@@ -18,6 +18,7 @@
 
 /**
  * Class that handles all engine related functions.
+ * @api ai
  */
 class ScriptEngine : public ScriptObject {
 public:
--- a/src/script/api/script_enginelist.hpp
+++ b/src/script/api/script_enginelist.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Create a list of engines based on a vehicle type.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptEngineList : public ScriptList {
--- a/src/script/api/script_error.hpp
+++ b/src/script/api/script_error.hpp
@@ -40,6 +40,7 @@
 
 /**
  * Class that handles all error related functions.
+ * @api ai
  */
 class ScriptError : public ScriptObject {
 public:
@@ -142,10 +143,9 @@
 	 */
 	static char *GetLastErrorString();
 
-#ifndef EXPORT_SKIP
 	/**
 	 * Get the error based on the OpenTTD StringID.
-	 * @note DO NOT INVOKE THIS METHOD YOURSELF!
+	 * @api -all
 	 * @param internal_string_id The string to convert.
 	 * @return The NoAI equivalent error message.
 	 */
@@ -153,7 +153,7 @@
 
 	/**
 	 * Map an internal OpenTTD error message to its NoAI equivalent.
-	 * @note DO NOT INVOKE THIS METHOD YOURSELF! The calls are autogenerated.
+	 * @api -all
 	 * @param internal_string_id The OpenTTD StringID used for an error.
 	 * @param ai_error_msg The NoAI equivalent error message.
 	 */
@@ -161,12 +161,11 @@
 
 	/**
 	 * Map an internal OpenTTD error message to its NoAI equivalent.
-	 * @note DO NOT INVOKE THIS METHOD YOURSELF! The calls are autogenerated.
+	 * @api -all
 	 * @param ai_error_msg The NoAI error message representation.
 	 * @param message The string representation of this error message, used for debug purposes.
 	 */
 	static void RegisterErrorMapString(ScriptErrorType ai_error_msg, const char *message);
-#endif /* EXPORT_SKIP */
 
 private:
 	typedef std::map<StringID, ScriptErrorType> ScriptErrorMap;           ///< The type for mapping between error (internal OpenTTD) StringID to the AI error type.
--- a/src/script/api/script_event.hpp
+++ b/src/script/api/script_event.hpp
@@ -18,6 +18,7 @@
  * Class that handles all event related functions.
  * You can lookup the type, and than convert it to the real event-class.
  * That way you can request more detailed information about the event.
+ * @api ai
  */
 class ScriptEvent : public ScriptObject {
 public:
@@ -72,6 +73,7 @@
 
 /**
  * Class that handles all event related functions.
+ * @api ai
  * @note it is not needed to create an instance of ScriptEvent to access it, as
  *  all members are static, and all data is stored AI-wide.
  */
@@ -89,20 +91,18 @@
 	 */
 	static ScriptEvent *GetNextEvent();
 
-#ifndef EXPORT_SKIP
 	/**
 	 * Insert an event to the queue for the company.
 	 * @param event The event to insert.
-	 * @note DO NOT CALL YOURSELF; leave it to the internal AI programming.
+	 * @api -all
 	 */
 	static void InsertEvent(ScriptEvent *event);
 
 	/**
 	 * Free the event pointer.
-	 * @note DO NOT CALL YOURSELF; leave it to the internal AI programming.
+	 * @api -all
 	 */
 	static void FreeEventPointer();
-#endif /* EXPORT_SKIP */
 
 private:
 	/**
--- a/src/script/api/script_event_types.hpp
+++ b/src/script/api/script_event_types.hpp
@@ -18,6 +18,7 @@
 /**
  * Event Vehicle Crash, indicating a vehicle of yours is crashed.
  *  It contains the crash site, the crashed vehicle and the reason for the crash.
+ * @api ai
  */
 class ScriptEventVehicleCrashed : public ScriptEvent {
 public:
@@ -78,6 +79,7 @@
 
 /**
  * Event Subsidy Offered, indicating someone offered a subsidy.
+ * @api ai
  */
 class ScriptEventSubsidyOffer : public ScriptEvent {
 public:
@@ -108,6 +110,7 @@
 
 /**
  * Event Subsidy Offer Expired, indicating a subsidy will no longer be awarded.
+ * @api ai
  */
 class ScriptEventSubsidyOfferExpired : public ScriptEvent {
 public:
@@ -138,6 +141,7 @@
 
 /**
  * Event Subidy Awarded, indicating a subsidy is awarded to some company.
+ * @api ai
  */
 class ScriptEventSubsidyAwarded : public ScriptEvent {
 public:
@@ -168,6 +172,7 @@
 
 /**
  * Event Subsidy Expired, indicating a route that was once subsidized no longer is.
+ * @api ai
  */
 class ScriptEventSubsidyExpired : public ScriptEvent {
 public:
@@ -200,6 +205,7 @@
  * Event Engine Preview, indicating a manufacturer offer you to test a new engine.
  *  You can get the same information about the offered engine as a real user
  *  would see in the offer window. And you can also accept the offer.
+ * @api ai
  */
 class ScriptEventEnginePreview : public ScriptEvent {
 public:
@@ -288,6 +294,7 @@
 
 /**
  * Event Company New, indicating a new company has been created.
+ * @api ai
  */
 class ScriptEventCompanyNew : public ScriptEvent {
 public:
@@ -319,6 +326,7 @@
 /**
  * Event Company In Trouble, indicating a company is in trouble and might go
  *  bankrupt soon.
+ * @api ai
  */
 class ScriptEventCompanyInTrouble : public ScriptEvent {
 public:
@@ -349,6 +357,7 @@
 
 /**
  * Event Company Ask Merger, indicating a company can be bought (cheaply) by you.
+ * @api ai
  */
 class ScriptEventCompanyAskMerger : public ScriptEvent {
 public:
@@ -396,6 +405,7 @@
 /**
  * Event Company Merger, indicating a company has been bought by another
  *  company.
+ * @api ai
  */
 class ScriptEventCompanyMerger : public ScriptEvent {
 public:
@@ -438,6 +448,7 @@
 
 /**
  * Event Company Bankrupt, indicating a company has gone bankrupt.
+ * @api ai
  */
 class ScriptEventCompanyBankrupt : public ScriptEvent {
 public:
@@ -468,6 +479,7 @@
 
 /**
  * Event Vehicle Lost, indicating a vehicle can't find its way to its destination.
+ * @api ai
  */
 class ScriptEventVehicleLost : public ScriptEvent {
 public:
@@ -498,6 +510,7 @@
 
 /**
  * Event VehicleWaitingInDepot, indicating a vehicle has arrived a depot and is now waiting there.
+ * @api ai
  */
 class ScriptEventVehicleWaitingInDepot : public ScriptEvent {
 public:
@@ -528,6 +541,7 @@
 
 /**
  * Event Vehicle Unprofitable, indicating a vehicle lost money last year.
+ * @api ai
  */
 class ScriptEventVehicleUnprofitable : public ScriptEvent {
 public:
@@ -558,6 +572,7 @@
 
 /**
  * Event Industry Open, indicating a new industry has been created.
+ * @api ai
  */
 class ScriptEventIndustryOpen : public ScriptEvent {
 public:
@@ -588,6 +603,7 @@
 
 /**
  * Event Industry Close, indicating an industry is going to be closed.
+ * @api ai
  */
 class ScriptEventIndustryClose : public ScriptEvent {
 public:
@@ -618,6 +634,7 @@
 
 /**
  * Event Engine Available, indicating a new engine is available.
+ * @api ai
  */
 class ScriptEventEngineAvailable : public ScriptEvent {
 public:
@@ -648,6 +665,7 @@
 
 /**
  * Event Station First Vehicle, indicating a station has been visited by a vehicle for the first time.
+ * @api ai
  */
 class ScriptEventStationFirstVehicle : public ScriptEvent {
 public:
@@ -687,6 +705,7 @@
 
 /**
  * Event Disaster Zeppeliner Crashed, indicating a zeppeliner has crashed on an airport and is blocking the runway.
+ * @api ai
  */
 class ScriptEventDisasterZeppelinerCrashed : public ScriptEvent {
 public:
@@ -717,6 +736,7 @@
 
 /**
  * Event Disaster Zeppeliner Cleared, indicating a previously crashed zeppeliner has been removed, and the airport is operating again.
+ * @api ai
  */
 class ScriptEventDisasterZeppelinerCleared : public ScriptEvent {
 public:
@@ -747,6 +767,7 @@
 
 /**
  * Event Town Founded, indicating a new town has been created.
+ * @api ai
  */
 class ScriptEventTownFounded : public ScriptEvent {
 public:
--- a/src/script/api/script_execmode.hpp
+++ b/src/script/api/script_execmode.hpp
@@ -20,6 +20,7 @@
  *   Execute. The original mode is stored and recovered from when ever the
  *   instance is destroyed.
  * In Execute mode all commands you do are executed for real.
+ * @api ai
  */
 class ScriptExecMode : public ScriptObject {
 private:
--- a/src/script/api/script_gamesettings.hpp
+++ b/src/script/api/script_gamesettings.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all game settings related functions.
+ * @api ai
  *
  * @note ScriptGameSettings::IsValid and ScriptGameSettings::GetValue are functions
  *       that rely on the settings as OpenTTD stores them in savegame and
--- a/src/script/api/script_group.hpp
+++ b/src/script/api/script_group.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all group related functions.
+ * @api ai
  */
 class ScriptGroup : public ScriptObject {
 public:
--- a/src/script/api/script_grouplist.hpp
+++ b/src/script/api/script_grouplist.hpp
@@ -17,6 +17,7 @@
 /**
  * Creates a list of groups of which you are the owner.
  * @note Neither ScriptGroup::GROUP_ALL nor ScriptGroup::GROUP_DEFAULT is in this list.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptGroupList : public ScriptList {
--- a/src/script/api/script_industry.hpp
+++ b/src/script/api/script_industry.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all industry related functions.
+ * @api ai
  */
 class ScriptIndustry : public ScriptObject {
 public:
--- a/src/script/api/script_industrylist.hpp
+++ b/src/script/api/script_industrylist.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Creates a list of industries that are currently on the map.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptIndustryList : public ScriptList {
@@ -25,6 +26,7 @@
 
 /**
  * Creates a list of industries that accepts a given cargo.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptIndustryList_CargoAccepting : public ScriptList {
@@ -38,6 +40,7 @@
 /**
  * Creates a list of industries that can produce a given cargo.
  * @note It also contains industries that currently produces 0 units of the cargo.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptIndustryList_CargoProducing : public ScriptList {
--- a/src/script/api/script_industrytype.hpp
+++ b/src/script/api/script_industrytype.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all industry-type related functions.
+ * @api ai
  */
 class ScriptIndustryType : public ScriptObject {
 public:
--- a/src/script/api/script_industrytypelist.hpp
+++ b/src/script/api/script_industrytypelist.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Creates a list of valid industry types.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptIndustryTypeList : public ScriptList {
--- a/src/script/api/script_list.hpp
+++ b/src/script/api/script_list.hpp
@@ -21,6 +21,7 @@
 
 /**
  * Class that creates a list which can keep item/value pairs, which you can walk.
+ * @api ai
  */
 class ScriptList : public ScriptObject {
 public:
--- a/src/script/api/script_log.hpp
+++ b/src/script/api/script_log.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all log related functions.
+ * @api ai
  */
 class ScriptLog : public ScriptObject {
 	/* ScriptController needs access to Enum and Log, in order to keep the flow from
@@ -23,10 +24,10 @@
 	friend class ScriptController;
 
 public:
-#ifndef EXPORT_SKIP
 	/**
 	 * Log levels; The value is also feed to DEBUG() lvl.
 	 *  This has no use for you, as AI writer.
+	 * @api -all
 	 */
 	enum ScriptLogType {
 		LOG_SQ_ERROR = 0, ///< Squirrel printed an error.
@@ -39,6 +40,7 @@
 	/**
 	 * Internal representation of the log-data inside the AI.
 	 *  This has no use for you, as AI writer.
+	 * @api -all
 	 */
 	struct LogData {
 		char **lines;           ///< The log-lines.
@@ -47,7 +49,6 @@
 		int pos;                ///< Current position in lines.
 		int used;               ///< Total amount of used log-lines.
 	};
-#endif /* EXPORT_SKIP */
 
 	/**
 	 * Print an Info message to the logs.
@@ -67,13 +68,11 @@
 	 */
 	static void Error(const char *message);
 
-#ifndef EXPORT_SKIP
 	/**
 	 * Free the log pointer.
-	 * @note DO NOT CALL YOURSELF; leave it to the internal AI programming.
+	 * @api -all
 	 */
 	static void FreeLogPointer();
-#endif /* EXPORT_SKIP */
 
 private:
 	/**
--- a/src/script/api/script_map.hpp
+++ b/src/script/api/script_map.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Class that handles all map related functions.
+ * @api ai
  */
 class ScriptMap : public ScriptObject {
 public:
--- a/src/script/api/script_marine.hpp
+++ b/src/script/api/script_marine.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all marine related functions.
+ * @api ai
  */
 class ScriptMarine : public ScriptObject {
 public:
--- a/src/script/api/script_object.hpp
+++ b/src/script/api/script_object.hpp
@@ -29,10 +29,10 @@
  *   your script, as it doesn't publish any public functions. It is used
  *   internally to have a common place to handle general things, like internal
  *   command processing, and command-validation checks.
+ * @api none
  */
 class ScriptObject : public SimpleCountedObject {
 friend class ScriptInstance;
-#ifndef DOXYGEN_AI_DOCS
 protected:
 	/**
 	 * A class that handles the current active instance. By instantiating it at
@@ -239,7 +239,6 @@
 	 * @param group_id The new GroupID.
 	 */
 	static void SetNewGroupID(GroupID group_id);
-#endif /* DOXYGEN_AI_DOCS */
 };
 
 #endif /* SCRIPT_OBJECT_HPP */
--- a/src/script/api/script_order.hpp
+++ b/src/script/api/script_order.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all order related functions.
+ * @api ai
  */
 class ScriptOrder : public ScriptObject {
 public:
--- a/src/script/api/script_rail.hpp
+++ b/src/script/api/script_rail.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all rail related functions.
+ * @api ai
  */
 class ScriptRail : public ScriptObject {
 public:
--- a/src/script/api/script_railtypelist.hpp
+++ b/src/script/api/script_railtypelist.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Creates a list of all available railtypes.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptRailTypeList : public ScriptList {
--- a/src/script/api/script_road.hpp
+++ b/src/script/api/script_road.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all road related functions.
+ * @api ai
  */
 class ScriptRoad : public ScriptObject {
 public:
--- a/src/script/api/script_sign.hpp
+++ b/src/script/api/script_sign.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all sign related functions.
+ * @api ai
  */
 class ScriptSign : public ScriptObject {
 public:
--- a/src/script/api/script_signlist.hpp
+++ b/src/script/api/script_signlist.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Create a list of signs your company has created.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptSignList : public ScriptList {
--- a/src/script/api/script_station.hpp
+++ b/src/script/api/script_station.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Class that handles all station related functions.
+ * @api ai
  */
 class ScriptStation : public ScriptBaseStation {
 public:
--- a/src/script/api/script_stationlist.hpp
+++ b/src/script/api/script_stationlist.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Creates a list of stations of which you are the owner.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptStationList : public ScriptList {
@@ -29,6 +30,7 @@
 
 /**
  * Creates a list of stations which the vehicle has in its orders.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptStationList_Vehicle : public ScriptList {
--- a/src/script/api/script_subsidy.hpp
+++ b/src/script/api/script_subsidy.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all subsidy related functions.
+ * @api ai
  */
 class ScriptSubsidy : public ScriptObject {
 public:
--- a/src/script/api/script_subsidylist.hpp
+++ b/src/script/api/script_subsidylist.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Creates a list of all current subsidies.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptSubsidyList : public ScriptList {
--- a/src/script/api/script_testmode.hpp
+++ b/src/script/api/script_testmode.hpp
@@ -22,6 +22,7 @@
  * In Test mode all the commands you execute aren't really executed. The
  *   system only checks if it would be able to execute your requests, and what
  *   the cost would be.
+ * @api ai
  */
 class ScriptTestMode : public ScriptObject {
 private:
--- a/src/script/api/script_tile.hpp
+++ b/src/script/api/script_tile.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Class that handles all tile related functions.
+ * @api ai
  */
 class ScriptTile : public ScriptObject {
 public:
--- a/src/script/api/script_tilelist.hpp
+++ b/src/script/api/script_tilelist.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Creates an empty list, in which you can add tiles.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptTileList : public ScriptList {
@@ -57,6 +58,7 @@
 /**
  * Creates a list of tiles that will accept cargo for the given industry.
  * @note If a simular industry is close, it might happen that this industry receives the cargo.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptTileList_IndustryAccepting : public ScriptTileList {
@@ -73,6 +75,7 @@
 /**
  * Creates a list of tiles which the industry checks to see if a station is
  *  there to receive cargo produced by this industry.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptTileList_IndustryProducing : public ScriptTileList {
@@ -89,6 +92,7 @@
 /**
  * Creates a list of tiles which have the requested StationType of the
  *  StationID.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptTileList_StationType : public ScriptTileList {
--- a/src/script/api/script_town.hpp
+++ b/src/script/api/script_town.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Class that handles all town related functions.
+ * @api ai
  */
 class ScriptTown : public ScriptObject {
 public:
--- a/src/script/api/script_townlist.hpp
+++ b/src/script/api/script_townlist.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Creates a list of towns that are currently on the map.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptTownList : public ScriptList {
@@ -25,6 +26,7 @@
 
 /**
  * Creates a list of all TownEffects known in the game.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptTownEffectList : public ScriptList {
--- a/src/script/api/script_tunnel.hpp
+++ b/src/script/api/script_tunnel.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all tunnel related functions.
+ * @api ai
  */
 class ScriptTunnel : public ScriptObject {
 public:
--- a/src/script/api/script_vehicle.hpp
+++ b/src/script/api/script_vehicle.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all vehicle related functions.
+ * @api ai
  */
 class ScriptVehicle : public ScriptObject {
 public:
--- a/src/script/api/script_vehiclelist.hpp
+++ b/src/script/api/script_vehiclelist.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Creates a list of vehicles of which you are the owner.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptVehicleList : public ScriptList {
@@ -26,6 +27,7 @@
 
 /**
  * Creates a list of vehicles that have orders to a given station.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptVehicleList_Station : public ScriptList {
@@ -43,6 +45,7 @@
  * aircraft having a depot order on a hangar of that airport will be
  * returned. For all other vehicle types the tile has to be a depot or
  * an empty list will be returned.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptVehicleList_Depot : public ScriptList {
@@ -55,6 +58,7 @@
 
 /**
  * Creates a list of vehicles that share orders.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptVehicleList_SharedOrders : public ScriptList {
@@ -67,6 +71,7 @@
 
 /**
  * Creates a list of vehicles that are in a group.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptVehicleList_Group : public ScriptList {
@@ -79,6 +84,7 @@
 
 /**
  * Creates a list of vehicles that are in the default group.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptVehicleList_DefaultGroup : public ScriptList {
--- a/src/script/api/script_waypoint.hpp
+++ b/src/script/api/script_waypoint.hpp
@@ -16,6 +16,7 @@
 
 /**
  * Class that handles all waypoint related functions.
+ * @api ai
  */
 class ScriptWaypoint : public ScriptBaseStation {
 public:
--- a/src/script/api/script_waypointlist.hpp
+++ b/src/script/api/script_waypointlist.hpp
@@ -17,6 +17,7 @@
 
 /**
  * Creates a list of waypoints of which you are the owner.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptWaypointList : public ScriptList {
@@ -29,6 +30,7 @@
 
 /**
  * Creates a list of waypoints which the vehicle has in its orders.
+ * @api ai
  * @ingroup ScriptList
  */
 class ScriptWaypointList_Vehicle : public ScriptList {